[ https://issues.apache.org/jira/browse/NIFI-5813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17047382#comment-17047382 ]
Konstantin commented on NIFI-5813: ---------------------------------- Added template with reproduction. > ReplaceText regression: fails on mixed literal dollar signs and backreferences > ------------------------------------------------------------------------------ > > Key: NIFI-5813 > URL: https://issues.apache.org/jira/browse/NIFI-5813 > Project: Apache NiFi > Issue Type: Bug > Affects Versions: 1.8.0 > Reporter: Konstantin > Priority: Minor > Labels: regexp_replace, regression > Attachments: ReplaceText_regression.xml > > > We've got a bug with ReplaceText when in replacement value are both the > literal dollar signs and backreferences. > Our use case is preparing Mongo queries using the value passed in FlowFile. > The replacement looks like this: > {code:java} > {updatedTime: {$ne: $1}} > {code} > NiFi 1.7.1 iterates through this line > ([source|https://github.com/apache/nifi/blob/rel/nifi-1.7.1/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ReplaceText.java#L709]) > and correctly replaces only "$ne", leaving "$1" untouched. NiFi 1.8.0, on > the other hand, uses Matcher > ([source|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#L717]), > which escapes all and every dollar sign if it ever finds the need to escape > one, so the backreference is treated as literal replacement, and the query > fails. > We have to make a workaround right now by using several ReplaceText > processors in a row, but this looks rather ugly. Hoping to see this fixed. -- This message was sent by Atlassian Jira (v8.3.4#803005)