mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00

* Add `json_validate(string $json, int $depth = 512, int $flags = 0): bool` from https://wiki.php.net/rfc/json_validate * In json_validate, use a different set of C no-op functions for creating/updating arrays/objects when validating while reusing the unmodified parser/scanner code * Forbid unsupported flags in json_validate() * Remove test of passing NULL as parameter (normal behavior of https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg for internal functions) Co-authored-by: jcm <juan.carlos.morales@tradebyte.com>
47 lines
1.2 KiB
PHP
47 lines
1.2 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(56) "Malformed UTF-8 characters, possibly incorrectly encoded"
|
|
bool(false)
|
|
int(5)
|
|
string(56) "Malformed UTF-8 characters, possibly incorrectly encoded"
|
|
bool(false)
|
|
int(5)
|
|
string(56) "Malformed UTF-8 characters, possibly incorrectly encoded"
|
|
bool(false)
|
|
int(5)
|
|
string(56) "Malformed UTF-8 characters, possibly incorrectly encoded"
|
|
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"
|