summaryrefslogtreecommitdiff
path: root/tests/executor/preg_replace.phpt
diff options
context:
space:
mode:
authorBen Fuhrmannek2016-02-24 23:37:25 +0100
committerBen Fuhrmannek2016-02-24 23:37:25 +0100
commit09d9dfaaa94c69125ceb388c69bc18237837eec9 (patch)
tree034bcba1e0f8d5862c5feb0ed7795196ab1d3840 /tests/executor/preg_replace.phpt
parent4e3331cca770dfba2eaecdedd3c8a9fa78210873 (diff)
tests for preg_replace
Diffstat (limited to 'tests/executor/preg_replace.phpt')
-rw-r--r--tests/executor/preg_replace.phpt30
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..64d6671
--- /dev/null
+++ b/tests/executor/preg_replace.phpt
@@ -0,0 +1,30 @@
1--TEST--
2Testing protection against "\0" in preg_replace() first parameter
3--SKIPIF--
4<?php include "../skipif.inc"; ?>
5--INI--
6suhosin.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--
27string(49) "One little boy with 2 dogs, 3 cats and four birds"
28NULL
29string(39) "The three cats play with the four birds"
30NULL