Ver código fonte

merged branch Seldaek/urlgen (PR #1569)

Commits
-------

6039569 [Routing] Add # and ? to escaped chars

Discussion
----------

[Routing] Add # and ? to escaped chars

See comments on 761724ae57d07cee2368bee86a2f1fe22cf188fc
Fabien Potencier 14 anos atrás
pai
commit
2ec4b04547

+ 7 - 1
src/Symfony/Component/Routing/Generator/UrlGenerator.php

@@ -28,6 +28,12 @@ use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
 class UrlGenerator implements UrlGeneratorInterface
 {
     protected $context;
+    protected $escapedChars = array(
+        '%' => '%25',
+        '+' => '%2B',
+        '#' => '%23',
+        '?' => '%3F',
+    );
 
     private $routes;
     private $cache;
@@ -125,7 +131,7 @@ class UrlGenerator implements UrlGeneratorInterface
                     }
 
                     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;