Permalink
Browse files

Allow character classes in attribute patterns.

Fixes #3706
  • Loading branch information...
1 parent 60f9131 commit 246c09ae4030c1bbded2f4ad3d56fb971ca60eca @markstory markstory committed Mar 14, 2013
Showing with 5 additions and 1 deletion.
  1. +4 −0 lib/Cake/Test/Case/Utility/HashTest.php
  2. +1 −1 lib/Cake/Utility/Hash.php
@@ -873,6 +873,10 @@ public function testExtractAttributePattern() {
$result = Hash::extract($data, '{n}.Article[title=/^First/]');
$expected = array($data[0]['Article']);
$this->assertEquals($expected, $result);
+
+ $result = Hash::extract($data, '{n}.Article[title=/^Fir[a-z]+/]');
+ $expected = array($data[0]['Article']);
+ $this->assertEquals($expected, $result);
}
/**
@@ -170,7 +170,7 @@ protected static function _matchToken($key, $token) {
*/
protected static function _matches(array $data, $selector) {
preg_match_all(
- '/(\[ (?<attr>[^=><!]+?) (\s* (?<op>[><!]?[=]|[><]) \s* (?<val>[^\]]+) )? \])/x',
+ '/(\[ (?<attr>[^=><!]+?) (\s* (?<op>[><!]?[=]|[><]) \s* (?<val>(?:\/.*?\/ | [^\]]+)) )? \])/x',
$selector,
$conditions,
PREG_SET_ORDER

0 comments on commit 246c09a

Please sign in to comment.