Skip to content

Commit 4b1b7e2

Browse files
author
fate0
committed
Fixed ISSUE #3 remove json_encode
1 parent f78e967 commit 4b1b7e2

File tree

12 files changed

+41
-36
lines changed

12 files changed

+41
-36
lines changed

tests/002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ bool(false)
3939
bool(false)
4040
bool(true)
4141
bool(true)
42-
echo_handler:xmark: "aaaa" 1
42+
echo_handler:xmark: 'aaaa' 1
4343
aaaa

tests/base.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,41 @@ function xcheck_var($var, $recursive=true) {
2424
}
2525

2626

27+
function repr($var) {
28+
return addcslashes(var_export($var, true), "\n\r\t");
29+
}
30+
31+
2732
function echo_handler($string) {
2833
if (is_string($string) && xcheck($string)) {
29-
echo "echo_handler:xmark: ".json_encode($string)." ".xcheck($string)."\n";
34+
echo "echo_handler:xmark: ".repr($string)." ".xcheck($string)."\n";
3035
}
3136
}
3237

3338
function exit_handler($string) {
3439
if (is_string($string) && xcheck($string)) {
35-
echo "exit_handler:xmark: ".json_encode($string)." ".xcheck($string)."\n";
40+
echo "exit_handler:xmark: ".repr($string)." ".xcheck($string)."\n";
3641
}
3742
}
3843

3944
function init_user_dynamic_call_handler($funcname) {
4045
if (is_string($funcname)) {
4146
if (xcheck($funcname)) {
42-
echo "init_user_dynamic_call_handler:xcheck: ".json_encode($funcname)." ".xcheck($funcname)."\n";
47+
echo "init_user_dynamic_call_handler:xcheck: ".repr($funcname)." ".xcheck($funcname)."\n";
4348
}
4449
} else if (is_array($funcname)) {
4550
if (xcheck($funcname[0])) {
46-
echo "init_user_dynamic_call_handler:xcheck: ".json_encode($funcname[0])." ".xcheck($funcname[0])."\n";
51+
echo "init_user_dynamic_call_handler:xcheck: ".repr($funcname[0])." ".xcheck($funcname[0])."\n";
4752
}
4853
if (xcheck($funcname[1])) {
49-
echo "init_user_dynamic_call_handler:xcheck: ".json_encode($funcname[1])." ".xcheck($funcname[1])."\n";
54+
echo "init_user_dynamic_call_handler:xcheck: ".repr($funcname[1])." ".xcheck($funcname[1])."\n";
5055
}
5156
}
5257
}
5358

5459
function include_or_eval_handler($param) {
5560
if (xcheck($param)) {
56-
echo "include_or_eval_handler:xmark: ".json_encode($param)." ".xcheck($param)."\n";
61+
echo "include_or_eval_handler:xmark: ".repr($param)." ".xcheck($param)."\n";
5762
}
5863
}
5964

tests/taint-bug61816.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ var_dump(xcheck($c->foo));
2323
?>
2424
--EXPECT--
2525
bool(true)
26-
echo_handler:xmark: "tainted string.\n" 1
26+
echo_handler:xmark: 'tainted string.\n' 1
2727
tainted string.
2828
bool(true)

tests/taint-bug63123.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ foreach ($a as $key => $val) {
3535

3636
?>
3737
--EXPECT--
38-
echo_handler:xmark: "a\n" 1
38+
echo_handler:xmark: 'a\n' 1
3939
a
40-
echo_handler:xmark: "b\n" 1
40+
echo_handler:xmark: 'b\n' 1
4141
b

tests/taint002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ eval("return '$a';");
3535

3636
?>
3737
--EXPECT--
38-
echo_handler:xmark: "tainted string\n" 1
38+
echo_handler:xmark: 'tainted string\n' 1
3939
tainted string
4040
file_put_contents:xcheck: data 1
4141
tainted string+
42-
include_or_eval_handler:xmark: "return 'tainted string+';" 1
42+
include_or_eval_handler:xmark: 'return \'tainted string+\';' 1

tests/taint003.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ exit($b);
2222

2323
?>
2424
--EXPECT--
25-
echo_handler:xmark: "tainted string" 1
25+
echo_handler:xmark: 'tainted string' 1
2626
tainted string
2727
bool(true)
28-
exit_handler:xmark: "tainted stringxxxx" 1
28+
exit_handler:xmark: 'tainted stringxxxx' 1
2929
tainted stringxxxx

tests/taint004.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ die($b);
1717

1818
?>
1919
--EXPECT--
20-
exit_handler:xmark: "tainted string." 1
20+
exit_handler:xmark: 'tainted string.' 1
2121
tainted string.

tests/taint005.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ print $a;
2323

2424
?>
2525
--EXPECT--
26-
echo_handler:xmark: "tainted string\n" 1
26+
echo_handler:xmark: 'tainted string\n' 1
2727
tainted string
28-
echo_handler:xmark: "tainted string\n" 1
28+
echo_handler:xmark: 'tainted string\n' 1
2929
tainted string
30-
echo_handler:xmark: "tainted string\n" 1
30+
echo_handler:xmark: 'tainted string\n' 1
3131
tainted string
32-
echo_handler:xmark: "tainted string\n" 1
32+
echo_handler:xmark: 'tainted string\n' 1
3333
tainted string

tests/taint006.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ test2($e);
4545
?>
4646
--EXPECT--
4747
======= normal test ======
48-
echo_handler:xmark: "a tainted string\n" 1
48+
echo_handler:xmark: 'a tainted string\n' 1
4949
a tainted string
50-
echo_handler:xmark: "a tainted string\n" 1
50+
echo_handler:xmark: 'a tainted string\n' 1
5151
a tainted string
5252
======= normal a&b ======
53-
echo_handler:xmark: "a tainted string\n" 1
53+
echo_handler:xmark: 'a tainted string\n' 1
5454
a tainted string
55-
echo_handler:xmark: "a tainted string\n" 1
55+
echo_handler:xmark: 'a tainted string\n' 1
5656
a tainted string
5757
======= normal c&d ======
58-
echo_handler:xmark: "c tainted string\n" 1
58+
echo_handler:xmark: 'c tainted string\n' 1
5959
c tainted string
60-
echo_handler:xmark: "c tainted string\n" 1
60+
echo_handler:xmark: 'c tainted string\n' 1
6161
c tainted string

tests/taint011.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ echo $var;
2222

2323
?>
2424
--EXPECT--
25-
echo_handler:xmark: "tainted string\n" 1
25+
echo_handler:xmark: 'tainted string\n' 1
2626
tainted string
27-
echo_handler:xmark: "tainted string\n" 1
27+
echo_handler:xmark: 'tainted string\n' 1
2828
tainted string

0 commit comments

Comments
 (0)