You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by Sergei Zhirikov <sf...@yahoo.com.INVALID> on 2018/03/28 11:36:55 UTC
A bug in expression substitution
Hi,
It looks like I have stumbled upon a bug in substitution of evaluated expressions.
A test case:
String result = org.apache.nifi.attribute.expression.language.Query.prepare("${foo}$${foo}").evaluateExpressions(Collections.singletonMap("foo", "bar"), null);
Expected result: "bar${foo}"Observed result: "barbar"
The issue exists in 1.5.0 and, as far as I can tell, in the master branch.The cause is quite simple: Query.prepare(...) splits the input string into pieces to be evaluated and substituted or to be copied literally, but it doesn't keep track of which is which.That couldn't possibly work. If a piece to be copied literally happens to be equal to one of the pieces to be substituted, the things go wrong, as the test case demonstrates.
Regards,Sergei.
Re: A bug in expression substitution
Posted by Pierre Villard <pi...@gmail.com>.
Probably related to this JIRA:
https://issues.apache.org/jira/browse/NIFI-4407
2018-03-28 18:42 GMT+02:00 Mark Payne <ma...@hotmail.com>:
> Sergei,
>
> Thanks for reporting this! I have created a JIRA [1] to track this.
>
> -Mark
>
> [1] https://issues.apache.org/jira/browse/NIFI-5026
>
>
> On Mar 28, 2018, at 7:36 AM, Sergei Zhirikov <sfzhi@yahoo.com.INVALID<
> mailto:sfzhi@yahoo.com.INVALID>> wrote:
>
> Hi,
> It looks like I have stumbled upon a bug in substitution of evaluated
> expressions.
> A test case:
> String result = org.apache.nifi.attribute.expression.language.Query.
> prepare("${foo}$${foo}").evaluateExpressions(
> Collections.singletonMap("foo", "bar"), null);
> Expected result: "bar${foo}"Observed result: "barbar"
> The issue exists in 1.5.0 and, as far as I can tell, in the master
> branch.The cause is quite simple: Query.prepare(...) splits the input
> string into pieces to be evaluated and substituted or to be copied
> literally, but it doesn't keep track of which is which.That couldn't
> possibly work. If a piece to be copied literally happens to be equal to one
> of the pieces to be substituted, the things go wrong, as the test case
> demonstrates.
>
> Regards,Sergei.
>
>
>
Re: A bug in expression substitution
Posted by Mark Payne <ma...@hotmail.com>.
Sergei,
Thanks for reporting this! I have created a JIRA [1] to track this.
-Mark
[1] https://issues.apache.org/jira/browse/NIFI-5026
On Mar 28, 2018, at 7:36 AM, Sergei Zhirikov <sf...@yahoo.com.INVALID>> wrote:
Hi,
It looks like I have stumbled upon a bug in substitution of evaluated expressions.
A test case:
String result = org.apache.nifi.attribute.expression.language.Query.prepare("${foo}$${foo}").evaluateExpressions(Collections.singletonMap("foo", "bar"), null);
Expected result: "bar${foo}"Observed result: "barbar"
The issue exists in 1.5.0 and, as far as I can tell, in the master branch.The cause is quite simple: Query.prepare(...) splits the input string into pieces to be evaluated and substituted or to be copied literally, but it doesn't keep track of which is which.That couldn't possibly work. If a piece to be copied literally happens to be equal to one of the pieces to be substituted, the things go wrong, as the test case demonstrates.
Regards,Sergei.