Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / Routing / UrlGenerator.php
index 92326ec42a3f3d29d9fbf8a0525906e29418731c..853a5f7b4e1babda77e423a4777e49b433b12f2d 100644 (file)
@@ -148,7 +148,7 @@ class UrlGenerator implements UrlGeneratorInterface {
    * examined for changes in new Symfony releases.
    *
    * @param array $variables
-   *   The variables form the compiled route, corresponding to slugs in the
+   *   The variables from the compiled route, corresponding to slugs in the
    *   route path.
    * @param array $defaults
    *   The defaults from the route.
@@ -297,6 +297,11 @@ class UrlGenerator implements UrlGeneratorInterface {
     if ($options['path_processing']) {
       $path = $this->processPath($path, $options, $generated_url);
     }
+    // Ensure the resulting path has at most one leading slash, to prevent it
+    // becoming an external URL without a protocol like //example.com.
+    if (strpos($path, '//') === 0) {
+      $path = '/' . ltrim($path, '/');
+    }
     // The contexts base URL is already encoded
     // (see Symfony\Component\HttpFoundation\Request).
     $path = str_replace($this->decodedChars[0], $this->decodedChars[1], rawurlencode($path));