Skip to content

Commit d3eeb05

Browse files
bug #534 [8.3] Fix json_validate edge case (IonBazan)
This PR was merged into the 1.x branch. Discussion ---------- [8.3] Fix json_validate edge case Fixes an edge case where using a property containing a `\x00` character in property name produces incorrect result in `json_validate()`. Fixes #533 Commits ------- 621eaa3 Fix json_validate edge case
2 parents 634ccdf + 621eaa3 commit d3eeb05

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Php83/Php83.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static function json_validate(string $json, int $depth = 512, int $flags
3535
throw new \ValueError(sprintf('json_validate(): Argument #2 ($depth) must be less than %d', self::JSON_MAX_DEPTH));
3636
}
3737

38-
json_decode($json, null, $depth, $flags);
38+
json_decode($json, true, $depth, $flags);
3939

4040
return \JSON_ERROR_NONE === json_last_error();
4141
}

tests/Php83/Php83Test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public static function jsonDataProvider(): iterable
141141
yield [true, '{ "": { "": "" } }'];
142142
yield [true, '{ "test": {"foo": "bar"}, "test2": {"foo" : "bar" }, "test2": {"foo" : "bar" } }'];
143143
yield [true, '{ "test": {"foo": "bar"}, "test2": {"foo" : "bar" }, "test3": {"foo" : "bar" } }'];
144+
yield [true, '{ "\u0000null": "test" }'];
144145
yield [false, '{"key1":"value1", "key2":"value2"}', 'Maximum stack depth exceeded', 1];
145146
yield [false, "\"a\xb0b\"", 'Malformed UTF-8 characters, possibly incorrectly encoded'];
146147
yield [true, '{ "test": { "foo": "bar" } }', 'No error', 2147483647];

0 commit comments

Comments
 (0)