diff options
| author | Scott MacVicar <scottmac@php.net> | 2011-02-21 08:09:02 +0000 |
|---|---|---|
| committer | Scott MacVicar <scottmac@php.net> | 2011-02-21 08:09:02 +0000 |
| commit | ecb9d8019c4d63ad483fc8d1955e4e2de92a8a6f (patch) | |
| tree | 87d99da6751af969be7203f904e74ef102816e5c /ext/json/tests | |
| parent | 2a6968e43ae4dc6b91c44f59daa94b3a2b26fd51 (diff) | |
| download | php-git-ecb9d8019c4d63ad483fc8d1955e4e2de92a8a6f.tar.gz | |
Fix Bug #54058, invalid utf-8 doesn't set json_encode() in all cases
Diffstat (limited to 'ext/json/tests')
| -rw-r--r-- | ext/json/tests/bug54058.phpt | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ext/json/tests/bug54058.phpt b/ext/json/tests/bug54058.phpt new file mode 100644 index 0000000000..3b1136bdd9 --- /dev/null +++ b/ext/json/tests/bug54058.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #54058 (json_last_error() invalid UTF-8 produces wrong error) +--SKIPIF-- +<?php if (!extension_loaded("json")) print "skip"; ?> +--FILE-- +<?php + +$bad_utf8 = quoted_printable_decode('=B0'); + +json_encode($bad_utf8); +var_dump(json_last_error()); + +$a = new stdclass; +$a->foo = quoted_printable_decode('=B0'); +json_encode($a); +var_dump(json_last_error()); + +$b = new stdclass; +$b->foo = $bad_utf8; +$b->bar = 1; +json_encode($b); +var_dump(json_last_error()); + +$c = array( + 'foo' => $bad_utf8, + 'bar' => 1 +); +json_encode($c); +var_dump(json_last_error()); +?> +--EXPECTF-- +int(5) +int(5) +int(5) +int(5) |
