-
Notifications
You must be signed in to change notification settings - Fork 722
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
Don't swap spaces for commas. #395
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Are we worried about backward compatibility implications here? |
This causes tests to fail. Is the goal here to support the format like |
If peaople were using spaces to separate e-mails adresses, then yes that would be a problem.
Yes indeed. Right now to use it this way we need to add comma at the end of the mail to avoid character swapping. It isn't described anywhere and to find it I had to look into the code base. Online e-mail list splitters by default supports: comma, pipie, colon, new line |
We can't break people. Lots of places in Jenkins spaces are used for delimiters in a list. We should just parse this correctly, maybe we can use this: https://docs.oracle.com/javaee/5/api/javax/mail/internet/InternetAddress.html#parse(java.lang.String,%20boolean) |
The help for the address fields generally say to use commas (https://github.com/jenkinsci/email-ext-plugin/blob/c5914a98487eaaf2ee93fcd0059033a3d5806742/src/main/webapp/help/projectConfig/mailType/recipientList.html for instance) , but that doesn't mean people haven't been using spaces. We would need an upgrade path in a readResolve to look for |
Proper parsing of the e-mails would be way to go, but I'm afraid that there could be a lot of cases that will really complicate implementation.
I'm not sure if spaces should be allowed as a splitting character at all, the e-mail and the names should be visibly separated, either with adding quotes, using special character in between. What can be done?
If we can treat jenkins users as live organism we could:
|
private static String fixupDelimiters(String input) { | ||
input = input.trim(); | ||
input = input.replaceAll("\\s+", " "); | ||
if(input.contains(" ") && !input.contains(",")) { | ||
input = input.replace(" ", ","); | ||
} | ||
|
||
input = input.replace(';', ','); | ||
return input; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this?
private static String fixupDelimiters(String input) throws AddressException {
input = input.trim();
input = input.replaceAll("\\s+", " ");
input = input.replaceAll(";", ",");
if(input.contains(" ") && !input.contains(",") && !input.contains("<")) {
// fix-up spaces to commas
input = input.replaceAll(" ", ",");
}
return input;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't do that check comment with explanation:
#395 (comment)
I have the same issue, seems reasonable to make the code a bit smarter here so that an address like My workaround is to not use spaces :) |
bba8d33
to
3d111d7
Compare
@roboweaver you just reminded me about this PR. I thought it's long closed already. New (1e501f0) proposition solves:
There's a side defects: What can be done?
I don't really know why this test is failing: Is there an easy way to run tests locally? |
|
Superseded by #562 |
To avoid recipient list friendly name slicing while only one e-mail address is given.
https://issues.jenkins.io/browse/JENKINS-69681
N/A?
I've edited it in the browser, sorry no environment to run it, and implement tests.