com php-src: Fixed bug #69144 (strtr not replacing with partly matching replace pairs): ext/standard/string.c ext/standard/tests/strings/bug69144.phpt
| From: | Xinchen Hui | Date: | Sat, 28 Feb 2015 14:37:46 +0000 |
| Subject: | com php-src: Fixed bug #69144 (strtr not replacing with partly matching replace pairs): ext/standard/string.c ext/standard/tests/strings/bug69144.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-85129@lists.php.net to get a copy of this message | ||
Commit: 54e2020ee3e6142a86db03f1a9d47bc763334dbb
Author: Xinchen Hui <laruence@php.net> Sat, 28 Feb 2015 22:37:46 +0800
Parents: 49d19f6c7caafceefb0f0ac6f130fe0f99c80f38
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=54e2020ee3e6142a86db03f1a9d47bc763334dbb
Log:
Fixed bug #69144 (strtr not replacing with partly matching replace pairs)
Bugs:
https://bugs.php.net/69144
Changed paths:
M ext/standard/string.c
A ext/standard/tests/strings/bug69144.phpt
Diff:
diff --git a/ext/standard/string.c b/ext/standard/string.c
index b7e7128..b55abb7 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -3140,7 +3140,7 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable
*p
pos++;
}
}
- if (result.s && result.s->len) {
+ if (result.s) {
smart_str_appendl(&result, str + old_pos, slen - old_pos);
smart_str_0(&result);
RETVAL_STR(result.s);
diff --git a/ext/standard/tests/strings/bug69144.phpt b/ext/standard/tests/strings/bug69144.phpt
new file mode 100644
index 0000000..ded915b
--- /dev/null
+++ b/ext/standard/tests/strings/bug69144.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #69144 (strtr not replacing with partly matching replace pairs)
+--FILE--
+<?php
+$tests = array('bar' => '', 'foo' => 'o',
'foobar' => '', 'hello' => 'hello');
+
+foreach ($tests as $input => $expected) {
+ if ($expected !== ($actual = strtr($input, array("fo" => "",
"foobar" => "", "bar" => "")))) {
+ echo "KO
$input became $actual instead of
$expected\n";
+ }
+}
+echo "okey";
+?>
+--EXPECT--
+okey