@@ -166,6 +166,21 @@ private Attribute buildRegexAttribute(String key, String value, boolean negated,
166166 }
167167 }
168168
169+ private static boolean checkVarMatch (String key , String matchedString ,
170+ VariableStrings variableStrings , VariableStrings tempVariableStrings ) {
171+ String existingString = variableStrings .getString (key );
172+ if (existingString == null ) {
173+ existingString = tempVariableStrings .getString (key );
174+ }
175+ if (existingString != null && !existingString .equals (matchedString )) {
176+ return false ;
177+ }
178+ if (matchedString != null ) {
179+ tempVariableStrings .setVar (key , matchedString );
180+ }
181+ return true ;
182+ }
183+
169184 private boolean checkMatch (Attribute attr , boolean ignoreCase , String nodeValue ,
170185 VariableStrings variableStrings , VariableStrings tempVariableStrings ) {
171186 if (nodeValue == null ) {
@@ -179,29 +194,47 @@ private boolean checkMatch(Attribute attr, boolean ignoreCase, String nodeValue,
179194 boolean matches ;
180195 if (toMatch instanceof Boolean ) {
181196 matches = ((Boolean ) toMatch );
197+
198+ if (matches ) {
199+ for (Pair <Integer , String > varGroup : attr .variableGroups ) {
200+ // TODO possibly a bug here - it is not honoring ignoreCase
201+ String matchedString = nodeValue ;
202+ String key = varGroup .second ();
203+ if (!checkVarMatch (key , matchedString , variableStrings , tempVariableStrings )) {
204+ matches = false ;
205+ break ;
206+ }
207+ }
208+ }
182209 } else if (toMatch instanceof String ) {
183210 if (ignoreCase ) {
184211 matches = nodeValue .equalsIgnoreCase (toMatch .toString ());
185212 } else {
186213 matches = nodeValue .equals (toMatch .toString ());
187214 }
215+
216+ if (matches ) {
217+ for (Pair <Integer , String > varGroup : attr .variableGroups ) {
218+ // TODO possibly a bug here - it is not honoring ignoreCase
219+ String matchedString = nodeValue ;
220+ String key = varGroup .second ();
221+ if (!checkVarMatch (key , matchedString , variableStrings , tempVariableStrings )) {
222+ matches = false ;
223+ break ;
224+ }
225+ }
226+ }
188227 } else if (toMatch instanceof Pattern ) {
189228 Matcher matcher = ((Pattern ) toMatch ).matcher (nodeValue );
190229 if (matcher .matches ()) {
191230 matches = true ;
192231 for (Pair <Integer , String > varGroup : attr .variableGroups ) {
193- String existingString = variableStrings .getString (varGroup .second ());
194- if (existingString == null ) {
195- existingString = tempVariableStrings .getString (varGroup .second ());
196- }
197232 String matchedString = matcher .group (varGroup .first ());
198- if (existingString != null && !existingString .equals (matchedString )) {
233+ String key = varGroup .second ();
234+ if (!checkVarMatch (key , matchedString , variableStrings , tempVariableStrings )) {
199235 matches = false ;
200236 break ;
201237 }
202- if (matchedString != null ) {
203- tempVariableStrings .setVar (varGroup .second (), matchedString );
204- }
205238 }
206239 } else {
207240 matches = false ;
0 commit comments