Fixed another String::tokenize bug, closes #4627

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6852 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
the_undefined 2008-05-13 21:22:10 +00:00
parent 2334a27f51
commit 3db8b860d1
2 changed files with 22 additions and 4 deletions

View file

@ -138,6 +138,7 @@ class String extends Object {
$buffer = '';
$results = array();
$length = strlen($data);
$open = false;
while ($offset <= $length) {
$tmpOffset = -1;
@ -155,11 +156,24 @@ class String extends Object {
} else {
$buffer .= $data{$tmpOffset};
}
if ($leftBound != $rightBound) {
if ($data{$tmpOffset} == $leftBound) {
$depth++;
} elseif ($data{$tmpOffset} == $rightBound) {
}
if ($data{$tmpOffset} == $rightBound) {
$depth--;
}
} else {
if ($data{$tmpOffset} == $leftBound) {
if (!$open) {
$depth++;
$open = true;
} else {
$depth--;
$open = false;
}
}
}
$offset = ++$tmpOffset;
} else {
$results[] = $buffer . substr($data, $offset);

View file

@ -133,6 +133,10 @@ class StringTest extends UnitTestCase {
$result = String::tokenize('"single tag"', ' ', '"', '"');
$expected = array('"single tag"');
$this->assertEqual($expected, $result);
$result = String::tokenize('tagA "single tag" tagB', ' ', '"', '"');
$expected = array('tagA', '"single tag"', 'tagB');
$this->assertEqual($expected, $result);
}
}
?>