@@ -166,6 +166,21 @@ private Attribute buildRegexAttribute(String key, String value, boolean negated,
166
166
}
167
167
}
168
168
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
+
169
184
private boolean checkMatch (Attribute attr , boolean ignoreCase , String nodeValue ,
170
185
VariableStrings variableStrings , VariableStrings tempVariableStrings ) {
171
186
if (nodeValue == null ) {
@@ -179,29 +194,47 @@ private boolean checkMatch(Attribute attr, boolean ignoreCase, String nodeValue,
179
194
boolean matches ;
180
195
if (toMatch instanceof Boolean ) {
181
196
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
+ }
182
209
} else if (toMatch instanceof String ) {
183
210
if (ignoreCase ) {
184
211
matches = nodeValue .equalsIgnoreCase (toMatch .toString ());
185
212
} else {
186
213
matches = nodeValue .equals (toMatch .toString ());
187
214
}
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
+ }
188
227
} else if (toMatch instanceof Pattern ) {
189
228
Matcher matcher = ((Pattern ) toMatch ).matcher (nodeValue );
190
229
if (matcher .matches ()) {
191
230
matches = true ;
192
231
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
- }
197
232
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 )) {
199
235
matches = false ;
200
236
break ;
201
237
}
202
- if (matchedString != null ) {
203
- tempVariableStrings .setVar (varGroup .second (), matchedString );
204
- }
205
238
}
206
239
} else {
207
240
matches = false ;
0 commit comments