Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-5026

Expression Language Query.prepare function can sometimes ignore escape sequence

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.6.0
    • Component/s: Core Framework
    • Labels:
      None

      Description

      As reported on the dev@n.a.o mailing list:

       

      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.

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                markap14 Mark Payne
                Reporter:
                markap14 Mark Payne
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: