NIFI-8475: Fixed EL query parser when input contains multiple escaped expressions

Signed-off-by: Matthew Burgess <mattyb149@apache.org>

This closes #5031
This commit is contained in:
Peter Turcsanyi 2021-04-26 19:07:52 +02:00 committed by Matthew Burgess
parent 786f17182b
commit f11c99f9ec
No known key found for this signature in database
GPG Key ID: 05D3DEB8126DAD24
2 changed files with 13 additions and 0 deletions

View File

@ -336,6 +336,7 @@ public class Query {
}
addLiteralsAndParameters(parameterParser, treeText, expressions, true);
lastIndex = range.getEnd() + 1;
}
if (escapedRanges.isEmpty()) {

View File

@ -123,6 +123,18 @@ public class TestQuery {
final PreparedQuery mixedQuery = Query.prepare("${foo}$${foo}");
final String mixedEvaluated = mixedQuery.evaluateExpressions(new StandardEvaluationContext(variables), null);
assertEquals("bar${foo}", mixedEvaluated);
final PreparedQuery multipleEscapedQuery = Query.prepare("$${foo}$${bar}");
final String multipleEscapedEvaluated = multipleEscapedQuery.evaluateExpressions(new StandardEvaluationContext(variables), null);
assertEquals("${foo}${bar}", multipleEscapedEvaluated);
final PreparedQuery multipleEscapedWithTextQuery = Query.prepare("foo$${foo}bar$${bar}");
final String multipleEscapedWithTextEvaluated = multipleEscapedWithTextQuery.evaluateExpressions(new StandardEvaluationContext(variables), null);
assertEquals("foo${foo}bar${bar}", multipleEscapedWithTextEvaluated);
final PreparedQuery multipleMixedQuery = Query.prepare("foo${foo}$${foo}bar${bar}$${bar}");
final String multipleMixedEvaluated = multipleMixedQuery.evaluateExpressions(new StandardEvaluationContext(variables), null);
assertEquals("foobar${foo}bar${bar}", multipleMixedEvaluated);
}
private void assertValid(final String query) {