jakartaee / jakartaee/mail-api

InternetAddress validation is not conforming to RFC822

Open
#747 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

duplicate TCK
Dominant language
Java
Stars
285
Forks
109
Avg merge
15h 19m
Merged PRs (30d)
1

Description

**Describe the bug**
InternetAddress `checkAddress` validation is not conforming to RFC822 due to this line: https://github.com/jakartaee/mail-api/blob/892fae4ac7601976ee3270040a5b16d6349ce955/api/src/main/java/jakarta/mail/internet/InternetAddress.java#L1351

It should be `if (c <= 040 || c >= 0177)` to prevent characters above Octal 177 / Decimal 127 being accepted as valid.

Reference links:
- RFC822: https://www.ietf.org/rfc/rfc822.txt
- Link which says this class checks syntax rules of RFC 822: https://jakarta.ee/specifications/mail/1.6/apidocs/javax/mail/internet/internetaddress / https://docs.oracle.com/javaee/6/api/javax/mail/internet/InternetAddress.html

**To Reproduce**
Steps to reproduce the behavior:
```
new InternetAddress("testächar@something.com", true);

or

InternetAddress address = new InternetAddress("testächar@something.com");
address.validate();
```
The above code doesn't throw `AddressException`

**Expected behavior**

The expection is for this error to be thrown https://github.com/jakartaee/mail-api/blob/892fae4ac7601976ee3270040a5b16d6349ce955/api/src/main/java/jakarta/mail/internet/InternetAddress.java#L1352-L1353

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Mail server:**
- Protocol being used: [e.g. smtp, imap, pop3, etc.]
- Vendor/product: [e.g. Microsoft Exchange]
- Mail service URL: [e.g. gmail.com]

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in api/src/main/java/jakarta/mail/internet/InternetAddress.java at the checkAddress validation around line 1351. Reproduce the issue with the provided non-ASCII address using the constructor or validate() call, then verify that it raises AddressException as expected. Done means characters above decimal 127 are rejected according to RFC822.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.