diff --git a/src/Symfony/Component/Routing/Generator/UrlGenerator.php b/src/Symfony/Component/Routing/Generator/UrlGenerator.php index ed543ef0a0da..b0d3e0927cd2 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGenerator.php +++ b/src/Symfony/Component/Routing/Generator/UrlGenerator.php @@ -28,6 +28,12 @@ class UrlGenerator implements UrlGeneratorInterface { protected $context; + protected $escapedChars = array( + '%' => '%25', + '+' => '%2B', + '#' => '%23', + '?' => '%3F', + ); private $routes; private $cache; @@ -125,7 +131,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa } if (!$isEmpty || !$optional) { - $url = $token[1].strtr($tparams[$token[3]], array('%'=>'%25', '+'=>'%2B')).$url; + $url = $token[1].strtr($tparams[$token[3]], $this->escapedChars).$url; } $optional = false;