Skip to content
This repository was archived by the owner on Feb 20, 2020. It is now read-only.

Commit 1f017ae

Browse files
committed
Dots in local part of emails not handled properly - fix #322
1 parent 8869af1 commit 1f017ae

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

doc/release/CHANGES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ GH 315 empty Content-Transfer-Encoding header causes IOException
2828
GH 316 starttls.enable documentation should reference starttls.required prop
2929
GH 317 use System.lineSeparator() instead of System.getProperty(...)
3030
GH 321 URLName.getURL() returns incorrect url.
31+
GH 322 Dots in local part of emails not handled properly
3132

3233

3334
CHANGES IN THE 1.6.1 RELEASE

mail/src/main/java/javax/mail/internet/InternetAddress.java

+10
Original file line numberDiff line numberDiff line change
@@ -1343,12 +1343,22 @@ private static void checkAddress(String addr,
13431343
throw new AddressException(
13441344
"Quoted local address contains newline without whitespace",
13451345
addr);
1346+
} else if (c == '.') {
1347+
if (i == start)
1348+
throw new AddressException(
1349+
"Local address starts with dot", addr);
1350+
if (lastc == '.')
1351+
throw new AddressException(
1352+
"Local address contains dot-dot", addr);
13461353
}
13471354
if (inquote)
13481355
continue;
13491356
if (c == '@') {
13501357
if (i == 0)
13511358
throw new AddressException("Missing local name", addr);
1359+
if (lastc == '.')
1360+
throw new AddressException(
1361+
"Local address ends with dot", addr);
13521362
break; // done with local part
13531363
}
13541364
if (c <= 040 || c == 0177)

mail/src/test/resources/javax/mail/internet/addrlist

+6
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,12 @@ To: a@com.
395395
Expect: Exception javax.mail.internet.AddressException: Domain ends with dot in string ``a@com.''
396396
To: a@b..com
397397
Expect: Exception javax.mail.internet.AddressException: Domain contains dot-dot in string ``a@b..com''
398+
To: .a@b.com
399+
Expect: Exception javax.mail.internet.AddressException: Local address starts with dot in string ``.a@b.com''
400+
To: a.@b.com
401+
Expect: Exception javax.mail.internet.AddressException: Local address ends with dot in string ``a.@b.com''
402+
To: a..b@b.com
403+
Expect: Exception javax.mail.internet.AddressException: Local address contains dot-dot in string ``a..b@b.com''
398404
To: a@com
399405
Expect: Exception javax.mail.internet.AddressException: Domain contains control or whitespace in string ``a@com''
400406
To: a@b.com

0 commit comments

Comments
 (0)