Skip to content

Commit

Permalink
Fixing error in String::insert where string that contained a question…
Browse files Browse the repository at this point in the history
… mark were not propperly replaced
  • Loading branch information
lorenzo authored and markstory committed Oct 13, 2009
1 parent 24c82e7 commit 6dbb869
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/string.php
Expand Up @@ -236,7 +236,7 @@ function insert($str, $data, $options = array()) {
);
}

if (strpos($str, '?') !== false) {
if (strpos($str, '?') !== false && is_numeric(key($data))) {
$offset = 0;
while (($pos = strpos($str, '?', $offset)) !== false) {
$val = array_shift($data);
Expand Down
7 changes: 7 additions & 0 deletions cake/tests/cases/libs/string.test.php
Expand Up @@ -279,6 +279,13 @@ function testTokenize() {
$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);
}
}

?>

0 comments on commit 6dbb869

Please sign in to comment.