mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 11:37:16 +02:00
AK: Treat empty string as invalid JSON
Previously we would treat the empty string as `null`. This caused
JavaScript like this to fail:
```js
var object = {};
try {
object = JSON.parse("");
} catch {}
var array = object.array || [];
```
Since `JSON.parse("")` returned null instead of throwing, it would set
`object` to null and then try and use it instead of using the default
backup value.
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 09:31:35 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/da25ac0d48 Pull-request: https://github.com/SerenityOS/serenity/pull/14549
@@ -29,6 +29,7 @@ test("syntax errors", () => {
|
||||
"[1,2,3, ]",
|
||||
'{ "foo": "bar",}',
|
||||
'{ "foo": "bar", }',
|
||||
"",
|
||||
].forEach(test => {
|
||||
expect(() => {
|
||||
JSON.parse(test);
|
||||
|
||||
Reference in New Issue
Block a user