Browse Source

Merge pull request #430 from KowalczykBartek/bug-fix/issue-428

Prevent StackOverflow in case of unclosed property
pull/517/head
kallestenflo 6 years ago committed by GitHub
parent
commit
00dbe255d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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