mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing error in String::insert where string that contained a question mark were not propperly replaced
This commit is contained in:
parent
24c82e73c1
commit
6dbb8690ad
2 changed files with 8 additions and 1 deletions
|
@ -236,7 +236,7 @@ class String {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($str, '?') !== false) {
|
if (strpos($str, '?') !== false && is_numeric(key($data))) {
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
while (($pos = strpos($str, '?', $offset)) !== false) {
|
while (($pos = strpos($str, '?', $offset)) !== false) {
|
||||||
$val = array_shift($data);
|
$val = array_shift($data);
|
||||||
|
|
|
@ -279,6 +279,13 @@ class StringTest extends CakeTestCase {
|
||||||
$expected = array('tagA', '"single tag"', 'tagB');
|
$expected = array('tagA', '"single tag"', 'tagB');
|
||||||
$this->assertEqual($expected, $result);
|
$this->assertEqual($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testReplaceWithQuestionMarkInString() {
|
||||||
|
$string = ':a, :b and :c?';
|
||||||
|
$expected = '2 and 3?';
|
||||||
|
$result = String::insert($string, array('b' => 2, 'c' => 3), array('clean' => true));
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in a new issue