summaryrefslogtreecommitdiff
path: root/tests/executor/preg_replace_error.phpt
diff options
context:
space:
mode:
authorStefan Esser2010-02-21 11:44:54 +0100
committerStefan Esser2010-02-21 11:44:54 +0100
commit36dbfacbe64697d959f524e537b15b73c090d898 (patch)
treef1c7ce1409b0e7765fc72d550546967fcf0f9717 /tests/executor/preg_replace_error.phpt
Inital commit
Diffstat (limited to 'tests/executor/preg_replace_error.phpt')
-rw-r--r--tests/executor/preg_replace_error.phpt32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/executor/preg_replace_error.phpt b/tests/executor/preg_replace_error.phpt
new file mode 100644
index 0000000..39e0aee
--- /dev/null
+++ b/tests/executor/preg_replace_error.phpt
@@ -0,0 +1,32 @@
1--TEST--
2Testing protection against "\0" in preg_replace() first parameter (INCL. SUHOSIN ERROR MESSAGES)
3--SKIPIF--
4<?php include "../skipifnotcli.inc"; ?>
5--INI--
6suhosin.log.sapi=64
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--EXPECTF--
27string(49) "One little boy with 2 dogs, 3 cats and four birds"
28ALERT - string termination attack on first preg_replace parameter detected (attacker 'REMOTE_ADDR not set', file '%s', line 14)
29bool(false)
30string(39) "The three cats play with the four birds"
31ALERT - string termination attack on first preg_replace parameter detected (attacker 'REMOTE_ADDR not set', file '%s', line 16)
32bool(false)