Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should the String DeduplicateConcat separator be escaped? #40

Open
m607123 opened this issue Jul 20, 2017 · 1 comment
Open

Should the String DeduplicateConcat separator be escaped? #40

m607123 opened this issue Jul 20, 2017 · 1 comment
Labels
question Specific query about part of the codebase
Milestone

Comments

@m607123
Copy link
Contributor

m607123 commented Jul 20, 2017

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?

@m607123 m607123 added the question Specific query about part of the codebase label Jul 20, 2017
@m607123 m607123 changed the title String Deduplicate Concat separator requires escaping Should the String DeduplicateConcat separator be escaped? Nov 1, 2017
@xudien
Copy link

xudien commented Oct 26, 2020

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"

@n3101 n3101 added this to the v2_backlog milestone Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Specific query about part of the codebase
Projects
None yet
Development

No branches or pull requests

3 participants