Skip to content

Commit 71a09c1

Browse files
authored
Check for the existence of the next significant bracket (#985)
1 parent 900ebfe commit 71a09c1

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,11 @@ private boolean readBracketPropertyToken(PathTokenAppender appender) {
625625
fail("Property has not been closed - missing closing " + potentialStringDelimiter);
626626
}
627627

628-
int endBracketIndex = path.indexOfNextSignificantChar(endPosition, CLOSE_SQUARE_BRACKET) + 1;
628+
int endBracketIndex = path.indexOfNextSignificantChar(endPosition, CLOSE_SQUARE_BRACKET);
629+
if(endBracketIndex == -1) {
630+
fail("Property has not been closed - missing closing ]");
631+
}
632+
endBracketIndex++;
629633

630634
path.setPosition(endBracketIndex);
631635

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.jayway.jsonpath;
2+
3+
import org.junit.Test;
4+
5+
import static org.assertj.core.api.Assertions.assertThatNoException;
6+
7+
public class Issue_970 {
8+
@Test
9+
public void shouldNotCauseStackOverflow() {
10+
assertThatNoException().isThrownBy(() -> Criteria.where("[']',"));
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.jayway.jsonpath;
2+
3+
import org.junit.Test;
4+
5+
import static org.assertj.core.api.Assertions.*;
6+
7+
public class Issue_973 {
8+
@Test
9+
public void shouldNotCauseStackOverflow() {
10+
assertThatNoException().isThrownBy(() -> Criteria.parse("@[\"\",/\\"));
11+
}
12+
}

0 commit comments

Comments
 (0)