You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the input strings are handled, they are split using the .split() method, which uses RegEx - however if the user inputs a character that can be interpreted by RegEx ( pipe symbol, open parentheses etc ) it won't be escaped, and the output will then be incorrect.
What would be the best way to handle this - sanitise the inputs, throw an error, or request that the user input a valid delimiter instead?
The text was updated successfully, but these errors were encountered:
I think it's a BUG (not a question). Using Pattern to split the separator should require escape the regex special characters such as pipe symbol, etc. I'm using the StringDeduplicateConcat with pipe symbol as separator and it fails to concat. IMHO, it should use StringUtils.split(aString, separator) rather than Pattern without escaping special characters for regex.
Here is my unit test, which is failed
`
public void testApplyWithPipeCharacter() {
StringDeduplicateConcat op = new StringDeduplicateConcat();
op.setSeparator("|");
String concatString = op.apply("COMMON_NAME|MY_NAME","COMMON_NAME|YOUR_NAME");
Assert.assertEquals("Should return correct value", "COMMON_NAME|MY_NAME|YOUR_NAME", concatString);
}
`
The current code return wrong value: "C|O|M|N|_|A|E||Y|U|R"
When the input strings are handled, they are split using the .split() method, which uses RegEx - however if the user inputs a character that can be interpreted by RegEx ( pipe symbol, open parentheses etc ) it won't be escaped, and the output will then be incorrect.
What would be the best way to handle this - sanitise the inputs, throw an error, or request that the user input a valid delimiter instead?
The text was updated successfully, but these errors were encountered: