Skip to content

Commit b8fd9d0

Browse files
authored
Merge pull request #94 from johnjaylward/FixMLInfiniteLoop
new test case for issue 484
2 parents 6dcd82a + a24db2c commit b8fd9d0

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/java/org/json/junit/JSONMLTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,4 +803,30 @@ public void testToJSONObject_reversibility() {
803803
//
804804
// assertEquals(expectedJsonString, actualJsonString);
805805
// }
806+
807+
@Test (timeout = 6000)
808+
public void testIssue484InfinteLoop1() {
809+
try {
810+
JSONML.toJSONObject("??*^M??|?CglR^F??`??>?w??PIlr^E??D^X^]?$?-^R?o??O?*??{OD?^FY??`2a????NM?b^Tq?:O?>S$^K?J?^FB.gUK?m^H??zE??^??!v]?^A???^[^A??^U?c??????h???s???g^Z???`?q^Dbi??:^QZl?)?}1^??k?0??:$V?$?Ovs(}J??^V????2;^QgQ?^_^A?^D?^U?Tg?K?`?h%c?hmGA?<!C*^P^Y?^X9?~?t?)??,z^XA???S}?Q??.q?j????]");
811+
fail("Exception expected for invalid JSON.");
812+
} catch (JSONException ex) {
813+
assertEquals("Exception string did not match: ",
814+
"Unterminated string at 271 [character 272 line 1]",
815+
ex.getMessage());
816+
}
817+
}
818+
819+
@Test (timeout = 6000)
820+
public void testIssue484InfinteLoop2() {
821+
try {
822+
String input = "??*\n" +
823+
"??|?CglR??`??>?w??PIlr??D?$?-?o??O?*??{OD?Y??`2a????NM?bq?:O?>S$ ?J?B.gUK?m\b??zE???!v]???????c??????h???s???g???`?qbi??:Zl?)?}1^??k?0??:$V?$?Ovs(}J??????2;gQ????Tg?K?`?h%c?hmGA?<!C*?9?~?t?)??,zA???S}?Q??.q?j????]";
824+
JSONML.toJSONObject(input);
825+
fail("Exception expected for invalid JSON.");
826+
} catch (JSONException ex) {
827+
assertEquals("Exception string did not match: ",
828+
"Unterminated string at 242 [character 238 line 2]",
829+
ex.getMessage());
830+
}
831+
}
806832
}

0 commit comments

Comments
 (0)