Skip to content

InternetAddress does not ignore comments in angled address spec #749

@barracudarin

Description

@barracudarin

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.)

$ clj -Sdeps '{:deps {jakarta.mail/jakarta.mail-api {:mvn/version "2.1.3"}}}'
Clojure 1.12.0
user=> (import 'jakarta.mail.internet.InternetAddress)
jakarta.mail.internet.InternetAddress
user=> (def address "\"John Doe\" <[email protected] (John Doe)>")
#'user/address
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)))
"[email protected] (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 from newer RFCs. However that section does also state:

Though these syntactic forms MUST NOT be generated according to the grammar in section 3, they MUST be accepted and parsed by a conformant receiver.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions