Skip to content

Commit

Permalink
Fixed issue with Set::extract() where conditions containing a space a…
Browse files Browse the repository at this point in the history
…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 9, 2010
1 parent 59b8327 commit 5e454c1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/set.php
Expand Up @@ -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);
Expand Down
33 changes: 33 additions & 0 deletions cake/tests/cases/libs/set.test.php
Expand Up @@ -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,
Expand Down

0 comments on commit 5e454c1

Please sign in to comment.