mirror of https://github.com/apache/nifi.git
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:
parent
786f17182b
commit
f11c99f9ec
|
@ -336,6 +336,7 @@ public class Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
addLiteralsAndParameters(parameterParser, treeText, expressions, true);
|
addLiteralsAndParameters(parameterParser, treeText, expressions, true);
|
||||||
|
lastIndex = range.getEnd() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (escapedRanges.isEmpty()) {
|
if (escapedRanges.isEmpty()) {
|
||||||
|
|
|
@ -123,6 +123,18 @@ public class TestQuery {
|
||||||
final PreparedQuery mixedQuery = Query.prepare("${foo}$${foo}");
|
final PreparedQuery mixedQuery = Query.prepare("${foo}$${foo}");
|
||||||
final String mixedEvaluated = mixedQuery.evaluateExpressions(new StandardEvaluationContext(variables), null);
|
final String mixedEvaluated = mixedQuery.evaluateExpressions(new StandardEvaluationContext(variables), null);
|
||||||
assertEquals("bar${foo}", mixedEvaluated);
|
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) {
|
private void assertValid(final String query) {
|
||||||
|
|
Loading…
Reference in New Issue