Commit 50fd1f58 by Alexander Makarov

Bug: `yii\web\UrlRule` was unable to create URLs for rules containing unicode characters

parent 99a818c0
...@@ -14,6 +14,7 @@ Yii Framework 2 Change Log ...@@ -14,6 +14,7 @@ Yii Framework 2 Change Log
- Bug #5682: The `asset` command would incorrectly combine CSS files when `UrlManager::linkAssets` is true (dmvslv) - Bug #5682: The `asset` command would incorrectly combine CSS files when `UrlManager::linkAssets` is true (dmvslv)
- Bug #5702: Parenthesis should be automatically added to `Validator::whenClient` to avoid js error (mdmunir, qiangxue) - Bug #5702: Parenthesis should be automatically added to `Validator::whenClient` to avoid js error (mdmunir, qiangxue)
- Bug: Gii console command help information does not contain global options (qiangxue) - Bug: Gii console command help information does not contain global options (qiangxue)
- Bug: `yii\web\UrlRule` was unable to create URLs for rules containing unicode characters (samdark)
- Enh #5223: Query builder now supports selecting sub-queries as columns (qiangxue) - Enh #5223: Query builder now supports selecting sub-queries as columns (qiangxue)
- Enh #5587: `json_encode` is now used with `JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE` where it makes sense, also - Enh #5587: `json_encode` is now used with `JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE` where it makes sense, also
it is now default for `Json::encode()` (samdark) it is now default for `Json::encode()` (samdark)
......
...@@ -185,7 +185,7 @@ class UrlRule extends Object implements UrlRuleInterface ...@@ -185,7 +185,7 @@ class UrlRule extends Object implements UrlRuleInterface
if (isset($this->_routeParams[$name])) { if (isset($this->_routeParams[$name])) {
$tr2["<$name>"] = "(?P<$name>$pattern)"; $tr2["<$name>"] = "(?P<$name>$pattern)";
} else { } else {
$this->_paramRules[$name] = $pattern === '[^\/]+' ? '' : "#^$pattern$#"; $this->_paramRules[$name] = $pattern === '[^\/]+' ? '' : "#^$pattern$#u";
} }
} }
} }
......
...@@ -362,6 +362,16 @@ class UrlRuleTest extends TestCase ...@@ -362,6 +362,16 @@ class UrlRuleTest extends TestCase
['post/index', ['page' => 1, 'tag' => 'a', 'lang' => 'en'], 'http://en.example.com/post/a'], ['post/index', ['page' => 1, 'tag' => 'a', 'lang' => 'en'], 'http://en.example.com/post/a'],
], ],
], ],
[
'with unicode',
[
'pattern' => '/blog/search/<tag:[a-zA-Zа-яА-Я0-9\_\+\-]{1,255}>',
'route' => 'blog/search',
],
[
['blog/search', ['tag' => 'метра'], 'blog/search/%D0%BC%D0%B5%D1%82%D1%80%D0%B0'],
],
],
]; ];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment