From f010fb57b4cb3ebc3f8b1d65c5f85d166110fff9 Mon Sep 17 00:00:00 2001 From: Tadas Z Date: Mon, 4 Aug 2014 00:07:36 +0300 Subject: [PATCH] Enh #4581: Added ability to disable url encoding in `UrlRule`. --- framework/CHANGELOG.md | 1 + framework/web/UrlRule.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 65bdc05df1..2efcab83c7 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -169,6 +169,7 @@ Yii Framework 2 Change Log - Enh #4485: Added support for deferred validation in `ActiveForm` (Alex-Code) - Enh #4520: Added sasl support to `yii\caching\MemCache` (xjflyttp) - Enh #4566: Added client validation support for image validator (Skysplit, qiangxue) +- Enh #4581: Added ability to disable url encoding in `UrlRule` (tadaszelvys) - Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue) - Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue) - Enh: Added `yii\web\UrlManager::addRules()` to simplify adding new URL rules (qiangxue) diff --git a/framework/web/UrlRule.php b/framework/web/UrlRule.php index 18d5d32484..8387f4908b 100644 --- a/framework/web/UrlRule.php +++ b/framework/web/UrlRule.php @@ -83,6 +83,10 @@ class UrlRule extends Object implements UrlRuleInterface * If it is [[CREATION_ONLY]], the rule is for URL creation only. */ public $mode; + /** + * @var bool a value indicating if parameters should be url encoded. + */ + public $encodeParams = true; /** * @var string the template for generating a new URL. This is derived from [[pattern]] and is used in generating URL. @@ -310,7 +314,7 @@ class UrlRule extends Object implements UrlRuleInterface // match params in the pattern foreach ($this->_paramRules as $name => $rule) { if (isset($params[$name]) && !is_array($params[$name]) && ($rule === '' || preg_match($rule, $params[$name]))) { - $tr["<$name>"] = urlencode($params[$name]); + $tr["<$name>"] = $this->encodeParams ? urlencode($params[$name]) : $params[$name]; unset($params[$name]); } elseif (!isset($this->defaults[$name]) || isset($params[$name])) { return false;