Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent infinite loop when a /* comment is not terminated #49

Merged
merged 1 commit into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/main/java/org/codehaus/jettison/json/JSONTokener.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ public char nextClean() throws JSONException {
if (next() == '/') {
break;
}
back();
}
}
break;
Expand Down
22 changes: 20 additions & 2 deletions src/test/java/org/codehaus/jettison/json/JSONArrayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@ public void testEscapingInArrayIsTrunedOff() throws JSONException {
String expectedValue = "[\"a string with / character\",{\"key\":\"http://example.com/foo\"}]";
assertEquals(expectedValue, array.toString());
}



public void testInfiniteLoop() {
String str = "[*/*A25] **";
try {
new JSONArray(str);
fail("Failure expected on malformed JSON");
} catch (JSONException ex) {
// expected
}
}

public void testInfiniteLoop2() {
String str = "[/";
try {
new JSONArray(str);
fail("Failure expected on malformed JSON");
} catch (JSONException ex) {
// expected
}
}
}