Skip to content
Permalink
Browse files

Fixed issue with Set::extract() where conditions containing a space a…

…nd a slash would fail. Fixes #1185

Signed-off-by: mark_story <mark@mark-story.com>
  • Loading branch information...
Phally authored and markstory committed Oct 8, 2010
1 parent 59b8327 commit 5e454c108f454d142d685b029ea226c3dd138c4a
Showing with 34 additions and 1 deletion.
  1. +1 −1 cake/libs/set.php
  2. +33 −0 cake/tests/cases/libs/set.test.php
@@ -394,7 +394,7 @@ function extract($path, $data = null, $options = array()) {
$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);
@@ -852,6 +852,39 @@ function testExtract() {
$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,

0 comments on commit 5e454c1

Please sign in to comment.
You can’t perform that action at this time.