Skip to content

Commit a0c4a0e

Browse files
committedSep 26, 2024··
fix: Handle unbalanced comment string
1 parent dc24879 commit a0c4a0e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed
 

‎subprojects/json-lib-core/src/main/java/org/kordamp/json/util/JSONTokener.java

+2
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ public char nextClean() {
203203
if (c == '*') {
204204
if (next() == '/') {
205205
break;
206+
} else if (!more()) {
207+
return 0;
206208
}
207209
back();
208210
}

‎subprojects/json-lib-core/src/test/java/org/kordamp/json/TestJSONSerializer.java

+9
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ public void testToJava_JSONObject_4() {
144144
assertEquals(beanB.getValue(), ((ValueBean) bb).getValue());
145145
}
146146

147+
public void testToJava_JSONObject_5() throws Exception {
148+
try {
149+
JSONObject.fromObject("/**");
150+
fail("Should have thrown a JSONException");
151+
} catch (JSONException expected) {
152+
// ok
153+
}
154+
}
155+
147156
public void testToJava_JSONObject_and_reset() throws Exception {
148157
String json = "{bool:true,integer:1,string:\"json\"}";
149158
JSONObject jsonObject = JSONObject.fromObject(json);

0 commit comments

Comments
 (0)
Please sign in to comment.