From 9de3005566acdc91de80ce58eeeab4fee36042c9 Mon Sep 17 00:00:00 2001 From: Michele Vivoda Date: Wed, 10 Sep 2025 02:21:16 +0200 Subject: [PATCH 1/2] Update JSONArray.java for #1007 fix array content starting with ',' in strict mode --- src/main/java/org/json/JSONArray.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/json/JSONArray.java b/src/main/java/org/json/JSONArray.java index c2e5c9a..7d12f98 100644 --- a/src/main/java/org/json/JSONArray.java +++ b/src/main/java/org/json/JSONArray.java @@ -105,6 +105,8 @@ public class JSONArray implements Iterable { if (nextChar == 0) { // array is unclosed. No ']' found, instead EOF throw x.syntaxError("Expected a ',' or ']'"); + } else if (nextChar==',' && jsonParserConfiguration.isStrictMode()) { + throw x.syntaxError("Array content starts with a ','"); } if (nextChar != ']') { x.back(); From 686c08489736e2cebda86264a3294b356cd091a3 Mon Sep 17 00:00:00 2001 From: Michele Vivoda Date: Wed, 10 Sep 2025 02:30:19 +0200 Subject: [PATCH 2/2] Update JSONTokener.java for #1007 fixed parse of `0.` in strict mode --- src/main/java/org/json/JSONTokener.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/json/JSONTokener.java b/src/main/java/org/json/JSONTokener.java index 05a6e34..07ff18c 100644 --- a/src/main/java/org/json/JSONTokener.java +++ b/src/main/java/org/json/JSONTokener.java @@ -509,6 +509,9 @@ public class JSONTokener { string = sb.toString().trim(); if ("".equals(string)) { throw this.syntaxError("Missing value"); + } else if (jsonParserConfiguration != null && + jsonParserConfiguration.isStrictMode() && string.endsWith(".")) { + throw this.syntaxError(String.format("Strict mode error: Value '%s' ends with dot", string)); } Object obj = JSONObject.stringToValue(string); // if obj is a boolean, look at string