Browse Source

Fixed the issue that dots in URL rules would match any character.

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
8bff031fc2
  1. 1
      framework/yii/web/UrlRule.php
  2. 11
      tests/unit/framework/web/UrlRuleTest.php

1
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';

11
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',

Loading…
Cancel
Save