vert-x3 / vertx-mail-client

Apache License 2.0
34 stars 33 forks source link

EmailAddress class doesn't handle parentheses in the display name properly per RFC5322 #218

Open lihaoz-barry opened 1 year ago

lihaoz-barry commented 1 year ago

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)" [sample@email.com](mailto:sample@email.com) 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 sample@email.com (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.

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)" [sample@email.com](mailto:sample@email.com)

The EmailAddress class will throw an IllegalArgumentException saying "Invalid email address"

This is not the expected behaviour as per RFC5322.