浏览代码

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 年之前
父节点
当前提交
2ec4b04547
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      src/Symfony/Component/Routing/Generator/UrlGenerator.php

+ 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;