diff --git a/src/Symfony/Component/Routing/Generator/UrlGenerator.php b/src/Symfony/Component/Routing/Generator/UrlGenerator.php index a67b1f41c64e..d9fc9507ee33 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -98,7 +98,8 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa throw new \InvalidArgumentException(sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given).', $token[3], $name, $requirements[$token[3]], $tparams[$token[3]])); } - $url = $token[1].urlencode($tparams[$token[3]]).$url; + // %2F is not valid in a URL, so we double encode it + $url = $token[1].str_replace('%2F', '%252F', urlencode($tparams[$token[3]])).$url; $optional = false; } } elseif ('text' === $token[0]) { diff --git a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php index 10eb8f9a0c7c..929b4af6c22e 100644 --- a/src/Symfony/Component/Routing/Matcher/UrlMatcher.php +++ b/src/Symfony/Component/Routing/Matcher/UrlMatcher.php @@ -91,7 +91,8 @@ protected function mergeDefaults($params, $defaults) $parameters = array_merge($this->defaults, $defaults); foreach ($params as $key => $value) { if (!is_int($key)) { - $parameters[$key] = urldecode($value); + // / are double-encoded as %2F is not valid in a URL (see UrlGenerator) + $parameters[$key] = str_replace('%2F', '/', urldecode($value)); } }