mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
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:
parent
2334a27f51
commit
3db8b860d1
2 changed files with 22 additions and 4 deletions
|
@ -138,6 +138,7 @@ class String extends Object {
|
|||
$buffer = '';
|
||||
$results = array();
|
||||
$length = strlen($data);
|
||||
$open = false;
|
||||
|
||||
while ($offset <= $length) {
|
||||
$tmpOffset = -1;
|
||||
|
@ -155,10 +156,23 @@ class String extends Object {
|
|||
} else {
|
||||
$buffer .= $data{$tmpOffset};
|
||||
}
|
||||
if ($data{$tmpOffset} == $leftBound) {
|
||||
$depth++;
|
||||
} elseif ($data{$tmpOffset} == $rightBound) {
|
||||
$depth--;
|
||||
if ($leftBound != $rightBound) {
|
||||
if ($data{$tmpOffset} == $leftBound) {
|
||||
$depth++;
|
||||
}
|
||||
if ($data{$tmpOffset} == $rightBound) {
|
||||
$depth--;
|
||||
}
|
||||
} else {
|
||||
if ($data{$tmpOffset} == $leftBound) {
|
||||
if (!$open) {
|
||||
$depth++;
|
||||
$open = true;
|
||||
} else {
|
||||
$depth--;
|
||||
$open = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
$offset = ++$tmpOffset;
|
||||
} else {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue