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

ReplaceText - Backreference escape issue in Regex Replace mode when using EL

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 1.3.0
    • Extensions
    • None

    Description

      When using ReplaceText in Regex Replace mode, $'s may be incorrectly interrupted as a backreference and escaped. Given input

      'ma$tt'

      and the following ReplaceText configuration:

      Search Value - (?s)(^.*$)
      Replacement Value - ${'$1'}
      Character Set - UTF-8
      Maximum Buffer Size - 1 MB
      Replacement Strategy - Regex Replace
      Evaluation Mode - Entire text
      

      The resulting output is

      'ma\$tt'

      The issue appears to be that this regular expression is too general [1]. This happens when the replacement string uses expression language. It appears as though all backreferences will be escaped.

      [1] https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ReplaceText.java#L500

      Attachments

        Issue Links

          Activity

            People

              mcgilman Matt Gilman
              mcgilman Matt Gilman
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: