jakartaee / jakartaee/mail-api
InternetAddress does not ignore comments in angled address spec
- Dominant language
- Java
- Stars
- 285
- Forks
- 109
- Avg merge
- 15h 19m
- Merged PRs (30d)
- 1
Description
**Describe the bug**
`InternetAddress.parse` does not handle comments within angled address specs.
**To Reproduce**
(These steps are in Clojure because that's what I have readily available; translating to pure Java should be very intuitive.)
```clojure
$ clj -Sdeps '{:deps {jakarta.mail/jakarta.mail-api {:mvn/version "2.1.3"}}}'
Clojure 1.12.0
user=> (import 'jakarta.mail.internet.InternetAddress)
user=> (def address "\"John Doe\" ")
user=> (InternetAddress. address)
Execution error (AddressException) at jakarta.mail.internet.InternetAddress/checkAddress (InternetAddress.java:1401).
Domain contains control or whitespace
user=> (.getAddress (first (InternetAddress/parseHeader address false)))
"john@company.com (John Doe)"
user=>
```
**Expected behavior**
Comment blocks should be ignored when found within angled address specs.
**Desktop (please complete the following information):**
- OS: Ubuntu 24.04
**Additional context**
This may fall under the [Obsolete Syntax](https://datatracker.ietf.org/doc/html/rfc5322#autoid-36) from newer RFCs. However that section does also state:
> Though these syntactic forms MUST NOT be generated according to the grammar in [section 3](https://datatracker.ietf.org/doc/html/rfc5322#section-3), they MUST be accepted and parsed by a conformant receiver.
Contributor guide
Research direction
Start with InternetAddress.java around the checkAddress call at line 1401, then trace the constructor, InternetAddress.parse, and parseHeader using the supplied angled-address example. Compare how comments are handled inside the angle brackets and confirm that parsing accepts the address while returning john@company.com without the comment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100