Skip to content

Commit

Permalink
[Routing] fixed the / problem in a URL segment
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Mar 9, 2011
1 parent e5b93e6 commit dded195
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/Routing/Generator/UrlGenerator.php
Expand Up @@ -98,8 +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]]));
}

// %2F is not valid in a URL, so we double encode it
$url = $token[1].str_replace('%2F', '%252F', urlencode($tparams[$token[3]])).$url;
// %2F is not valid in a URL, so we don't encode it (which is fine as the requirements explicitely allowed it)
$url = $token[1].str_replace('%2F', '/', urlencode($tparams[$token[3]])).$url;
$optional = false;
}
} elseif ('text' === $token[0]) {
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Routing/Matcher/UrlMatcher.php
Expand Up @@ -89,8 +89,7 @@ protected function mergeDefaults($params, $defaults)
$parameters = array_merge($this->defaults, $defaults);
foreach ($params as $key => $value) {
if (!is_int($key)) {
// / are double-encoded as %2F is not valid in a URL (see UrlGenerator)
$parameters[$key] = str_replace('%2F', '/', urldecode($value));
$parameters[$key] = urldecode($value);
}
}

Expand Down

0 comments on commit dded195

Please sign in to comment.