diff --git a/framework/yii/web/UrlRule.php b/framework/yii/web/UrlRule.php index ec73c92..10f0627 100644 --- a/framework/yii/web/UrlRule.php +++ b/framework/yii/web/UrlRule.php @@ -156,6 +156,7 @@ class UrlRule extends Object } } } + $tr['.'] = '\\.'; $this->_template = preg_replace('/<(\w+):?([^>]+)?>/', '<$1>', $this->pattern); $this->pattern = '#^' . trim(strtr($this->_template, $tr), '/') . '$#u'; diff --git a/tests/unit/framework/web/UrlRuleTest.php b/tests/unit/framework/web/UrlRuleTest.php index 0a0def4..5e57cb6 100644 --- a/tests/unit/framework/web/UrlRuleTest.php +++ b/tests/unit/framework/web/UrlRuleTest.php @@ -380,6 +380,17 @@ class UrlRuleTest extends TestCase ), ), array( + 'with dot', // https://github.com/yiisoft/yii/issues/2945 + array( + 'pattern' => 'posts.html', + 'route' => 'post/index', + ), + array( + array('posts.html', 'post/index'), + array('postsahtml', false), + ), + ), + array( 'creation only', array( 'pattern' => 'posts',