Skip to content

Commit 19f1cfc

Browse files
committed
Improve #818 test a bit
1 parent 327be0d commit 19f1cfc

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

src/test/java/com/fasterxml/jackson/failing/Fuzz51806JsonPointerParseTest.java

+32-7
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,49 @@
44
import com.fasterxml.jackson.core.JsonPointer;
55

66
// For https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=51806
7-
// (via databind, but we don't need that)
7+
// (reported as [core#818]
88
public class Fuzz51806JsonPointerParseTest extends BaseTest
99
{
1010
// Before fix, looks like this is enough to cause StackOverflowError
1111
private final static int TOO_DEEP_PATH = 6000;
1212

13-
// Verify that very deep/long (by number of segments) JsonPointer
14-
// may still be parsed ok
15-
public void testJsonPointerParseTail() throws Exception
13+
// Verify that a very deep/long (by number of segments) JsonPointer
14+
// may still be parsed ok, for "simple" case (no quoted chars)
15+
public void testJsonPointerParseTailSimple()
1616
{
17-
JsonPointer p = JsonPointer.compile(_generatePath(TOO_DEEP_PATH));
17+
_testJsonPointer(_generatePath(TOO_DEEP_PATH, false));
18+
}
19+
20+
public void testJsonPointerParseTailWithQuoted()
21+
{
22+
_testJsonPointer(_generatePath(TOO_DEEP_PATH, true));
23+
}
24+
25+
private void _testJsonPointer(String pathExpr)
26+
{
27+
JsonPointer p = JsonPointer.compile(pathExpr);
1828
assertNotNull(p);
29+
// But also verify it didn't change
30+
assertEquals(pathExpr, p.toString());
1931
}
2032

21-
private String _generatePath(int depth) {
33+
private String _generatePath(int depth, boolean escaped) {
2234
StringBuilder sb = new StringBuilder(4 * depth);
2335
for (int i = 0; i < depth; ++i) {
24-
sb.append("/a").append(depth);
36+
sb.append('/')
37+
.append((char) ('a' + i%25))
38+
.append(i);
39+
40+
if (escaped) {
41+
switch (i & 7) {
42+
case 1:
43+
sb.append("~0x");
44+
break;
45+
case 4:
46+
sb.append("~1y");
47+
break;
48+
}
49+
}
2550
}
2651
return sb.toString();
2752
}

0 commit comments

Comments
 (0)