From f3c79b5957bd518517879c0b3028bf858f734459 Mon Sep 17 00:00:00 2001 From: Dzhuneyt Ahmed Date: Thu, 3 Jan 2019 16:40:07 +0200 Subject: [PATCH 1/4] Add support for "u" modifier for Regex validators --- framework/helpers/BaseHtml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/helpers/BaseHtml.php b/framework/helpers/BaseHtml.php index 5b0440b2918..46987a359a3 100644 --- a/framework/helpers/BaseHtml.php +++ b/framework/helpers/BaseHtml.php @@ -2318,7 +2318,7 @@ public static function escapeJsRegularExpression($regexp) $pattern = substr($pattern, 0, $pos + 1); } if (!empty($flag)) { - $pattern .= preg_replace('/[^igm]/', '', $flag); + $pattern .= preg_replace('/[^igmu]/', '', $flag); } return $pattern; From a3502df76628d58d7662ebecb1b55771cf7643d8 Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Thu, 3 Jan 2019 20:45:47 +0200 Subject: [PATCH 2/4] Add support for "u" modifier for Regex validators --- tests/framework/helpers/HtmlTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/framework/helpers/HtmlTest.php b/tests/framework/helpers/HtmlTest.php index 8e1846e10a4..950a8c348b3 100644 --- a/tests/framework/helpers/HtmlTest.php +++ b/tests/framework/helpers/HtmlTest.php @@ -1800,6 +1800,11 @@ public function testEscapeJsRegularExpression() $expected = '/([a-z0-9-]+)/gim'; $actual = Html::escapeJsRegularExpression('/([a-z0-9-]+)/Ugimex'); $this->assertSame($expected, $actual); + + // Make sure that just allowed REGEX modifiers remain after the escaping + $expected = '/([a-z0-9-]+)/ugim'; + $actual = Html::escapeJsRegularExpression('/([a-z0-9-]+)/dugimex'); + $this->assertSame($expected, $actual); } public function testActiveDropDownList() From 132f28ec40dcc6f944fcac33efe370939340241f Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Thu, 3 Jan 2019 21:55:07 +0200 Subject: [PATCH 3/4] Add support for "u" modifier for Regex validators --- framework/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 6beda0fda14..e6acd6ca848 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 Change Log 2.0.16 under development ------------------------ +- Bug #16974: Regular Expression Validator to include support for 'u' (UTF-8) modifier - Chg #16941: Set `yii\console\controllers\MigrateController::useTablePrefix` to true as default value (GHopperMSK) - Bug #16966: Fix ArrayExpression support in related tables (GHopperMSK) - Bug #16891: Fixed Pagination::totalCount initialized incorrectly (taobig) From d41351ffb3593132e0cc73230f9d2efee9d2ffb0 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 3 Jan 2019 23:12:23 +0300 Subject: [PATCH 4/4] Update CHANGELOG.md --- framework/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index e6acd6ca848..7bd365ecb71 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,7 +4,7 @@ Yii Framework 2 Change Log 2.0.16 under development ------------------------ -- Bug #16974: Regular Expression Validator to include support for 'u' (UTF-8) modifier +- Bug #16974: Regular Expression Validator to include support for 'u' (UTF-8) modifier (Dzhuneyt) - Chg #16941: Set `yii\console\controllers\MigrateController::useTablePrefix` to true as default value (GHopperMSK) - Bug #16966: Fix ArrayExpression support in related tables (GHopperMSK) - Bug #16891: Fixed Pagination::totalCount initialized incorrectly (taobig)