jakartaee / jakartaee/mail-api
Improve support for Email Address Internationalization (EAI)
- Dominant language
- Java
- Stars
- 285
- Forks
- 109
- Avg merge
- 15h 19m
- Merged PRs (30d)
- 1
Description
EAI is defined in RFC6531 and is supported by Jakarta Mail with the SMTPUTF8 extension but some email addresses domains are considered invalid while they shouldn't when creating `InternetAddress`.
To fully support EAI, `InternetAddress.checkAddress` should be fixed.
We made some tests with various valid email addresses and noticed the following elements:
- if the domain part is not in normalization form NFC it is rejected
- some valid Unicode domains are not accepted
The local part is correctly handled in our test cases.
In order to fix the domain part handling, `InternetAddress.checkAddress` should implement IDNA 2008 support as defined in RFC5891, an easy fix is to check the conversion of the domain to A-label with ICU4j that offers a good compliance with IDNA 2008.
Our test were done on Android and written in Kotlin with Jakarta version 2.0.1 but platform and language should not change anything here.
Here is a Kotlin snippet to check IDN conversion to A-label:
```
boolean isDomainValid(String domain) {
int flags = IDNA.CHECK_BIDI | IDNA.CHECK_CONTEXTJ | IDNA.CHECK_CONTEXTO | IDNA.NONTRANSITIONAL_TO_ASCII | IDNA.USE_STD3_RULES;
IDNA idna = IDNA.getUTS46Instance(flags);
IDNA.Info info = new IDNA.Info();
idna.nameToASCII(domain, new StringBuilder(), info);
return !info.hasErrors();
}
```
Contributor guide
Research direction
Start with InternetAddress.checkAddress and the existing address-validation tests. Compare current domain handling with the RFC6531 and RFC5891 requirements and the ICU4j IDNA conversion shown in the issue. Done means valid non-NFC and Unicode domains are accepted while invalid domains remain rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100