Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for the existence of the next significant bracket #985

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,11 @@ private boolean readBracketPropertyToken(PathTokenAppender appender) {
fail("Property has not been closed - missing closing " + potentialStringDelimiter);
}

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

path.setPosition(endBracketIndex);

Expand Down
12 changes: 12 additions & 0 deletions json-path/src/test/java/com/jayway/jsonpath/Issue_970.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.jayway.jsonpath;

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThatNoException;

public class Issue_970 {
@Test
public void shouldNotCauseStackOverflow() {
assertThatNoException().isThrownBy(() -> Criteria.where("[']',"));
}
}
12 changes: 12 additions & 0 deletions json-path/src/test/java/com/jayway/jsonpath/Issue_973.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.jayway.jsonpath;

import org.junit.Test;

import static org.assertj.core.api.Assertions.*;

public class Issue_973 {
@Test
public void shouldNotCauseStackOverflow() {
assertThatNoException().isThrownBy(() -> Criteria.parse("@[\"\",/\\"));
}
}