Browse Source

Prevent StackOverflow in case of unclosed property

pull/430/head
Bartlomiej Kowalczyk 7 years ago
parent
commit
0b324ec7b8
  1. 4
      json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java
  2. 5
      json-path/src/test/java/com/jayway/jsonpath/old/JsonPathTest.java

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

@ -603,6 +603,10 @@ public class PathCompiler {
readPosition++;
}
if (inProperty){
fail("Property has not been closed - missing closing " + potentialStringDelimiter);
}
int endBracketIndex = path.indexOfNextSignificantChar(endPosition, CLOSE_SQUARE_BRACKET) + 1;
path.setPosition(endBracketIndex);

5
json-path/src/test/java/com/jayway/jsonpath/old/JsonPathTest.java

@ -322,5 +322,10 @@ public class JsonPathTest extends BaseTest {
}
}
@Test(expected = InvalidPathException.class)
//see https://github.com/json-path/JsonPath/issues/428
public void prevent_stack_overflow_error_when_unclosed_property() {
JsonPath.compile("$['boo','foo][?(@ =~ /bar/)]");
}
}

Loading…
Cancel
Save