jakartaee / jakartaee/mail-api

Parsing of mail addresses with personal name not correctly encoded

Open
#506 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

**To Reproduce**
The following code demonstrates the issue:

```
var address = new InternetAddress("Mäd Mäx");
System.out.println(address);
```
**Actual behaviour**
The output is not encoded:
```
"Mäd Mäx"
```
The description of `toString()` says:

> Convert this address into a RFC 822 / RFC 2047 encoded address.
> The resulting string contains only US-ASCII characters, and hence is mail-safe.

**Expected behavior**
The output should be encoded:
`=?UTF-8?Q?M=C3=A4d_M=C3=A4x?=
`

**Additional context**
I have added a workaround like that:
`address.setPersonal(address.getPersonal());`
It looks redundant, but it isn't. Afterwards it worked.

I took a look at the code, and it seems that `jakarta.mail.internet.InternetAddress.parse(String, boolean, boolean)` assumes that the personal name is already encoded. That is true for headers, not for ordinary text.

Seems to be similar to #379.

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 at jakarta.mail.internet.InternetAddress.parse(String, boolean, boolean), which the issue identifies as treating the personal name as already encoded. Compare that behavior with setPersonal(address.getPersonal()) and the documented toString() contract. Done means parsing the reproduced address produces an RFC 2047-encoded personal name while preserving the email address.

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
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.