Skip to content

Commit 79f5263

Browse files
committed
Merge pull request Netflix#251 from AutoScout24/emails-with-hash
Email validation regex now accepts emails with hash in alias (before-…
2 parents 9a2fcf4 + 6b5535a commit 79f5263

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/main/java/com/netflix/simianarmy/aws/AWSEmailNotifier.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public abstract class AWSEmailNotifier implements MonkeyEmailNotifier {
4040
/** The Constant LOGGER. */
4141
private static final Logger LOGGER = LoggerFactory.getLogger(AWSEmailNotifier.class);
4242
private static final String EMAIL_PATTERN =
43-
"^[_A-Za-z0-9-\\+\\.]+(.[_A-Za-z0-9-]+)*@"
43+
"^[_A-Za-z0-9-\\+\\.#]+(.[_A-Za-z0-9-#]+)*@"
4444
+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
4545

4646
private final Pattern emailPattern;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.netflix.simianarmy.aws;
2+
3+
import org.testng.Assert;
4+
import org.testng.annotations.Test;
5+
6+
// CHECKSTYLE IGNORE MagicNumberCheck
7+
public class TestAWSEmailNotifier extends AWSEmailNotifier {
8+
public TestAWSEmailNotifier() {
9+
super(null);
10+
}
11+
12+
@Override
13+
public String buildEmailSubject(String to) {
14+
return null;
15+
}
16+
17+
@Override
18+
public String[] getCcAddresses(String to) {
19+
return new String[0];
20+
}
21+
22+
@Override
23+
public String getSourceAddress(String to) {
24+
return null;
25+
}
26+
27+
@Test
28+
public void testEmailWithHashIsValid() {
29+
TestAWSEmailNotifier emailNotifier = new TestAWSEmailNotifier();
30+
Assert.assertTrue(emailNotifier.isValidEmail("#bla-#name@domain-test.com"), "Email with hash is not valid");
31+
}
32+
}

0 commit comments

Comments
 (0)