While attempting to validate some emails for a project I am currently working on, I took a look at the code in EmailValidator.java (v. 4.3.1-final) and realized that an email is considered invalid if the 'domain' part exceeds 63 characters, but according to the specs cited in the validator code (see below) the domain could be up to 255 characters.
Code:
private boolean matchPart(String part, Pattern pattern) {
try {
part = IDN.toASCII( part );
}
catch ( IllegalArgumentException e ) {
// occurs when the label is too long (>63, even though it should probably be 64 - see http://www.rfc-editor.org/errata_search.php?rfc=3696,
// practically that should not be a problem)
return false;
}
Matcher matcher = pattern.matcher( part );
return matcher.matches();
}
Quote:
In addition to restrictions on syntax, there is a length limit on
email addresses. That limit is a maximum of 64 characters (octets)
in the "local part" (before the "@") and a maximum of 255 characters
(octets) in the domain part (after the "@") for a total length of 320
characters. However, there is a restriction in RFC 2821 on the length of an
address in MAIL and RCPT commands of 254 characters. Since addresses
that do not fit in those fields are not normally useful, the upper
limit on address lengths should normally be considered to be 254.
Is this a bug in the validator? or is this the desired behavior?