Fixed issue with Set::extract() where conditions containing a space and a slash would fail. Fixes #1185

Signed-off-by: mark_story <mark@mark-story.com>
This commit is contained in:
Phally 2010-10-08 20:49:35 +02:00 committed by mark_story
parent 0e5613f63d
commit 0d86302404
2 changed files with 34 additions and 1 deletions

View file

@ -393,7 +393,7 @@ class Set {
$contexts = array($data);
}
}
$tokens = array_slice(preg_split('/(?<!=)\/(?![a-z-]*\])/', $path), 1);
$tokens = array_slice(preg_split('/(?<!=)\/(?![a-z-\s]*\])/', $path), 1);
do {
$token = array_shift($tokens);

View file

@ -855,6 +855,39 @@ class SetTest extends CakeTestCase {
$r = Set::extract('/file/.[type=application/zip]', $f);
$this->assertEqual($r, $expected);
$f = array(
array(
'file' => array(
'name' => 'zipfile.zip',
'type' => 'application/zip',
'tmp_name' => '/tmp/php178.tmp',
'error' => 0,
'size' => '564647'
)
),
array(
'file' => array(
'name' => 'zipfile2.zip',
'type' => 'application/x zip compressed',
'tmp_name' => '/tmp/php179.tmp',
'error' => 0,
'size' => '354784'
)
),
array(
'file' => array(
'name' => 'picture.jpg',
'type' => 'image/jpeg',
'tmp_name' => '/tmp/php180.tmp',
'error' => 0,
'size' => '21324'
)
)
);
$expected = array(array('name' => 'zipfile2.zip','type' => 'application/x zip compressed','tmp_name' => '/tmp/php179.tmp','error' => 0,'size' => '354784'));
$r = Set::extract('/file/.[type=application/x zip compressed]', $f);
$this->assertEqual($r, $expected);
$hasMany = array(
'Node' => array(
'id' => 1,