diff options
Diffstat (limited to 'tests/executor/preg_replace.phpt')
| -rw-r--r-- | tests/executor/preg_replace.phpt | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/executor/preg_replace.phpt b/tests/executor/preg_replace.phpt new file mode 100644 index 0000000..9060a29 --- /dev/null +++ b/tests/executor/preg_replace.phpt | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | --TEST-- | ||
| 2 | Testing protection against "\0" in preg_replace() first parameter | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php include "../skipif.inc"; ?> | ||
| 5 | --INI-- | ||
| 6 | suhosin.log.sapi=0 | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | |||
| 10 | $text1 = "One little boy with two dogs, three cats and four birds"; | ||
| 11 | $text2 = "The three cats eat the four birds"; | ||
| 12 | |||
| 13 | $regex_array = array("/one/", "/two/", "/three/"); | ||
| 14 | $regex_array0 = array("/one/\0", "/two/", "/three/"); | ||
| 15 | $replace_array = array("1", "2", "3"); | ||
| 16 | $regex = "/eat/"; | ||
| 17 | $regex0 = "/ea\0t/"; | ||
| 18 | $replace = "play with"; | ||
| 19 | |||
| 20 | var_dump(preg_replace($regex_array, $replace_array, $text1)); | ||
| 21 | var_dump(preg_replace($regex_array0, $replace_array, $text1)); | ||
| 22 | var_dump(preg_replace($regex, $replace, $text2)); | ||
| 23 | var_dump(preg_replace($regex0, $replace, $text2)); | ||
| 24 | |||
| 25 | ?> | ||
| 26 | --EXPECT-- | ||
| 27 | string(49) "One little boy with 2 dogs, 3 cats and four birds" | ||
| 28 | bool(false) | ||
| 29 | string(39) "The three cats play with the four birds" | ||
| 30 | bool(false) | ||
