Resolving issue #743

- Recursive depth issue found in JSONObject
- Recursive depth issue found in JSONArray
This commit is contained in:
sk02241994
2023-11-03 19:54:23 +05:30
parent 6dba7220e1
commit 6d811607dd
4 changed files with 83 additions and 10 deletions

View File

@@ -1417,4 +1417,25 @@ public class JSONArrayTest {
.put(2);
assertFalse(ja1.similar(ja3));
}
@Test(expected = JSONException.class)
public void testRecursiveDepth() {
HashMap<String, Object> map = new HashMap<>();
map.put("t", map);
new JSONArray().put(map);
}
@Test(expected = JSONException.class)
public void testRecursiveDepthAtPosition() {
HashMap<String, Object> map = new HashMap<>();
map.put("t", map);
new JSONArray().put(0, map);
}
@Test(expected = JSONException.class)
public void testRecursiveDepthArray() {
ArrayList<Object> array = new ArrayList<>();
array.add(array);
new JSONArray(array);
}
}