1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/json/tests/json_validate_004.phpt
Juan Morales b80ffc5b2e Json last error msg/error message with location error (#20629)
This slightly extend error messages with locations taken from scanner / parser
2026-01-03 18:34:19 +01:00

48 lines
1.3 KiB
PHP

--TEST--
json_validate() - Invalid UTF-8's
--FILE--
<?php
require_once("json_validate_requires.inc");
echo "Testing Invalid UTF-8" . PHP_EOL;
json_validate_trycatchdump("\"a\xb0b\"");
json_validate_trycatchdump("\"a\xd0\xf2b\"");
json_validate_trycatchdump("\"\x61\xf0\x80\x80\x41\"");
json_validate_trycatchdump("[\"\xc1\xc1\",\"a\"]");
json_validate_trycatchdump("\"a\xb0b\"", 512, JSON_INVALID_UTF8_IGNORE);
json_validate_trycatchdump("\"a\xd0\xf2b\"", 512, JSON_INVALID_UTF8_IGNORE);
json_validate_trycatchdump("\"\x61\xf0\x80\x80\x41\"", 512, JSON_INVALID_UTF8_IGNORE);
json_validate_trycatchdump("[\"\xc1\xc1\",\"a\"]", 512, JSON_INVALID_UTF8_IGNORE);
?>
--EXPECT--
Testing Invalid UTF-8
bool(false)
int(5)
string(74) "Malformed UTF-8 characters, possibly incorrectly encoded near location 1:1"
bool(false)
int(5)
string(74) "Malformed UTF-8 characters, possibly incorrectly encoded near location 1:1"
bool(false)
int(5)
string(74) "Malformed UTF-8 characters, possibly incorrectly encoded near location 1:1"
bool(false)
int(5)
string(74) "Malformed UTF-8 characters, possibly incorrectly encoded near location 1:2"
bool(true)
int(0)
string(8) "No error"
bool(true)
int(0)
string(8) "No error"
bool(true)
int(0)
string(8) "No error"
bool(true)
int(0)
string(8) "No error"