Github user ottobackwards commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2929#discussion_r210073535
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ReplaceText.java
 ---
    @@ -701,6 +709,27 @@ private static String wrapLiterals(String 
possibleLiteral) {
             return replacementFinal;
         }
     
    +    /**
    +     * Escapes Expression Language like text from content Strings.
    +     * <p>
    +     * Since we do regular expression replacement on the content and then 
do Expression Language
    +     * evaluations afterwards, it is possible that if there are Expression 
Language like text
    +     * in the content that they will be evaluated when they should not be.
    +     * </p>
    +     * <p>
    +     * This function is called to escape any such construct by prefixing a 
second $ to the ${...} text.
    +     * </p>
    +     *
    +     * @param content the content that may contain Expression Language 
like text
    +     * @return A {@code String} with any Expression Language text escaped 
with a $.
    +     */
    +    private static String escapeExpressionsInContent(String content) {
    +        if (!content.contains("${")) {
    +            return content;
    +        }
    +        return content.replaceAll("(\\$\\{.*\\})","\\$$1");
    --- End diff --
    
    If you look at https://github.com/apache/nifi/pull/2748 and 
https://issues.apache.org/jira/browse/NIFI-4272,  evaluation of the EL before 
the regex operations resulted in incorrect behavior.  So it is evaluated after 
now.


---

Reply via email to