From f3ac1a0d152f6ae5b4bc6e701b870fcd4c91eaf1 Mon Sep 17 00:00:00 2001 From: Jochen Berger Date: Thu, 18 Feb 2016 13:06:37 +0100 Subject: [PATCH] fail when there are multiple commas between subscriptions --- .../com/jayway/jsonpath/internal/path/PathCompiler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java b/json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java index bb860afe..9e2db4bb 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java +++ b/json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java @@ -560,6 +560,7 @@ public class PathCompiler { int endPosition = 0; boolean inProperty = false; boolean inEscape = false; + boolean lastSignificantWasComma = false; while (path.inBounds(readPosition)) { char c = path.charAt(readPosition); @@ -579,7 +580,13 @@ public class PathCompiler { } else { startPosition = readPosition + 1; inProperty = true; + lastSignificantWasComma = false; } + } else if (c == COMMA){ + if (lastSignificantWasComma){ + fail("Found empty property at index "+readPosition); + } + lastSignificantWasComma = true; } readPosition++; }