1
0
mirror of https://github.com/php/php-src.git synced 2026-04-25 17:08:14 +02:00
Files
archived-php-src/ext/json/tests/bug61537.phpt
T
Adam Harvey 3f3ad30c50 Fix bug #61537 (json_encode() incorrectly truncates/discards information) and
remove a test case that's now mooted by this fix.
2012-04-11 08:24:38 +08:00

31 lines
947 B
PHP

--TEST--
Bug #61537 (json_encode() incorrectly truncates/discards information)
--SKIPIF--
<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
$invalid_utf8 = "\x9f";
var_dump(json_encode($invalid_utf8), json_last_error());
var_dump(json_encode($invalid_utf8, JSON_PARTIAL_OUTPUT_ON_ERROR), json_last_error());
$invalid_utf8 = "an invalid sequen\xce in the middle of a string";
var_dump(json_encode($invalid_utf8), json_last_error());
var_dump(json_encode($invalid_utf8, JSON_PARTIAL_OUTPUT_ON_ERROR), json_last_error());
?>
--EXPECTF--
Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d
bool(false)
int(5)
Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d
string(4) "null"
int(5)
Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d
bool(false)
int(5)
Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d
string(4) "null"
int(5)