Github user ottobackwards commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2748#discussion_r193423188
--- Diff:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceText.java
---
@@ -1074,12 +1090,11 @@ public void testRegexWithBadCaptureGroup() throws
IOException {
runner.setProperty(ReplaceText.REPLACEMENT_STRATEGY,
ReplaceText.REGEX_REPLACE);
runner.setProperty(ReplaceText.EVALUATION_MODE,
ReplaceText.ENTIRE_TEXT);
+ exception.expect(AssertionError.class);
+ exception.expectMessage("java.lang.IndexOutOfBoundsException: No
group 1");
--- End diff --
so the issue is this:
```java
// If we find a back reference that is not valid, then we will treat it as
a literal string. For example, if we have 3 capturing
// groups and the Replacement Value has the value is "I owe $8 to him",
then we want to treat the $8 as a literal "$8", rather
// than attempting to use it as a back reference.
private static String escapeLiteralBackReferences(final String
unescaped, final int numCapturingGroups) {
if (numCapturingGroups == 0) {
return unescaped;
}
```
If there are no capture groups, we don't escape all the findings
---