Skip to content

Commit

Permalink
Change fixupDelimiters to more allow ,; delimeters in e-mail list.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajarzyn committed Dec 1, 2023
1 parent 3d111d7 commit 1e501f0
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/main/java/hudson/plugins/emailext/EmailRecipientUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class EmailRecipientUtils {
public static final int TO = 0;
public static final int CC = 1;
public static final int BCC = 2;

private static final String EMAIL_LIST_SPLIT_BY = "[ ;,]";

public static Set<InternetAddress> convertRecipientString(String recipientList, EnvVars envVars)
throws AddressException, UnsupportedEncodingException {
Expand Down Expand Up @@ -136,14 +138,23 @@ public FormValidation validateFormRecipientList(String recipientList) {
}

private static String fixupDelimiters(String input) {
input = input.trim();
input = input.replaceAll("\\s+", " ");
if (input.contains(" ") && !input.contains(",")) {
input = input.replace(" ", ",");
}
String[] splitEmailList = input.split(EMAIL_LIST_SPLIT_BY);
StringBuilder inputBuilder = new StringBuilder();
for(String s : splitEmailList)
{
if(!s.isEmpty())
{
inputBuilder.append(s);
if(!s.contains("@")) {
inputBuilder.append(" ");
}
else {
inputBuilder.append(",");
}
}

input = input.replace(';', ',');
return input;
}
return inputBuilder.toString();
}

public static boolean isAllowedDomain(String userName, TaskListener listener) {
Expand Down

0 comments on commit 1e501f0

Please sign in to comment.