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 | 3242016f283138486242e4c4f4c0b1a5ce2e000f (patch) | |
tree | fdf4ddbf946b8d6ac23cf1c0b9c311229c7d9d31 /ext/json/tests/bug54058.phpt | |
parent | 1b2d14c5e10cc024f97a257a00fbefdb3a906501 (diff) | |
download | php-git-3242016f283138486242e4c4f4c0b1a5ce2e000f.tar.gz |
Fix Bug #54058, invalid utf-8 doesn't set json_encode() in all cases
Diffstat (limited to 'ext/json/tests/bug54058.phpt')
-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) |