Apply corner-case fixes under instruction

This commit is contained in:
XIAYM-gh
2026-09-04 08:09:14 +08:00
parent bcbbc89568
commit 359b43d8df
5 changed files with 100 additions and 20 deletions
+5 -5
View File
@@ -80,7 +80,7 @@ public class JSONArray implements Iterable<Object> {
* @param x
* A JSONTokener
* @throws JSONException
* If there is a syntax error.
* If there is a syntax error.
*/
public JSONArray(JSONTokener x) throws JSONException {
this(x, x.getJsonParserConfiguration());
@@ -103,10 +103,10 @@ public class JSONArray implements Iterable<Object> {
*
* @param x A JSONTokener instance from which the JSONArray is constructed.
* @param jsonParserConfiguration A JSONParserConfiguration instance that controls the behavior of the parser.
* @param eofRequired A boolean that determines whether this array is the root.
* @param isInitial A boolean that determines whether this array is the root.
* @throws JSONException If a syntax error occurs during the construction of the JSONArray.
*/
JSONArray(JSONTokener x, JSONParserConfiguration jsonParserConfiguration, boolean eofRequired) throws JSONException {
JSONArray(JSONTokener x, JSONParserConfiguration jsonParserConfiguration, boolean isInitial) throws JSONException {
this();
if (x.nextClean() != '[') {
@@ -130,10 +130,10 @@ public class JSONArray implements Iterable<Object> {
x.back();
this.myArrayList.add(x.nextValue());
}
if (checkForSyntaxError(x, jsonParserConfiguration, eofRequired)) return;
if (checkForSyntaxError(x, jsonParserConfiguration, isInitial)) return;
}
} else {
if (eofRequired && jsonParserConfiguration.isStrictMode() && x.nextClean() != 0) {
if (isInitial && jsonParserConfiguration.isStrictMode() && x.nextClean() != 0) {
throw x.syntaxError("Strict mode error: Unparsed characters found at end of input text");
}
}