Skip to content

Commit 54e2020

Browse files
committed
Fixed bug #69144 (strtr not replacing with partly matching replace pairs)
1 parent 49d19f6 commit 54e2020

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

ext/standard/string.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3140,7 +3140,7 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
31403140
pos++;
31413141
}
31423142
}
3143-
if (result.s && result.s->len) {
3143+
if (result.s) {
31443144
smart_str_appendl(&result, str + old_pos, slen - old_pos);
31453145
smart_str_0(&result);
31463146
RETVAL_STR(result.s);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #69144 (strtr not replacing with partly matching replace pairs)
3+
--FILE--
4+
<?php
5+
$tests = array('bar' => '', 'foo' => 'o', 'foobar' => '', 'hello' => 'hello');
6+
7+
foreach ($tests as $input => $expected) {
8+
if ($expected !== ($actual = strtr($input, array("fo" => "", "foobar" => "", "bar" => "")))) {
9+
echo "KO `$input` became `$actual` instead of `$expected`\n";
10+
}
11+
}
12+
echo "okey";
13+
?>
14+
--EXPECT--
15+
okey

0 commit comments

Comments
 (0)