Fixing error in String::insert where string that contained a question mark were not propperly replaced

This commit is contained in:
José Lorenzo Rodríguez 2009-10-13 10:45:17 -04:30 committed by mark_story
parent 24c82e73c1
commit 6dbb8690ad
2 changed files with 8 additions and 1 deletions

View file

@ -236,7 +236,7 @@ class String {
);
}
if (strpos($str, '?') !== false) {
if (strpos($str, '?') !== false && is_numeric(key($data))) {
$offset = 0;
while (($pos = strpos($str, '?', $offset)) !== false) {
$val = array_shift($data);

View file

@ -279,6 +279,13 @@ class StringTest extends CakeTestCase {
$expected = array('tagA', '"single tag"', 'tagB');
$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);
}
}
?>