Skip to content

Commit

Permalink
fix: Handle unbalanced comment string
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Sep 26, 2024
1 parent dc24879 commit a0c4a0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ public char nextClean() {
if (c == '*') {
if (next() == '/') {
break;
} else if (!more()) {
return 0;
}
back();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ public void testToJava_JSONObject_4() {
assertEquals(beanB.getValue(), ((ValueBean) bb).getValue());
}

public void testToJava_JSONObject_5() throws Exception {
try {
JSONObject.fromObject("/**");
fail("Should have thrown a JSONException");
} catch (JSONException expected) {
// ok
}
}

public void testToJava_JSONObject_and_reset() throws Exception {
String json = "{bool:true,integer:1,string:\"json\"}";
JSONObject jsonObject = JSONObject.fromObject(json);
Expand Down

0 comments on commit a0c4a0e

Please sign in to comment.