vertx-mail-client
vertx-mail-client copied to clipboard
EmailAddress class doesn't handle parentheses in the display name properly per RFC5322
Questions
I found a bug in the EmailAddress class where it doesn't properly handle parentheses in the display name according to RFC5322.
Version
vertx-mail-client
Context
According to RFC5322, a valid mailbox is composed of a display name and an email address. The display name can be non-special characters or a quoted string, which can include parentheses. Thus, "display(name)" <[email protected]> should be a valid fullAddress value.
In the EmailAddress class's constructor, there is an if/else block that checks if the full address contains parentheses. If it does, the class treats it like it's in a legacy simple format such as [email protected] (displayname).
The issue is, if the full address contains parentheses but does not match the regex for the legacy format, the class throws an IllegalArgumentException saying it's an invalid email address. However, this address should be valid per the description given in RFC5322.
- Link to github project/gist
https://github.com/vert-x3/vertx-mail-client/blob/4.4/src/main/java/io/vertx/ext/mail/mailencoder/EmailAddress.java
Steps to reproduce
Provide an email address with parentheses in the display name to the EmailAddress class's constructor, such as "display(name)" <[email protected]>
The EmailAddress class will throw an IllegalArgumentException saying "Invalid email address"
This is not the expected behaviour as per RFC5322.