jakartaee / jakartaee/mail-api

Returning non-UTF-8 charset from getDefaultMIMECharset() provides negative value these days

Open
#346 5 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

[`getDefaultMIMECharset()`](https://github.com/eclipse-ee4j/javamail/blob/beab9265aa39a4c3c4a2e220b1e4c198060803a5/mail/src/main/java/javax/mail/internet/MimeUtility.java#L1316) tries to use a charset from a system property and falls back on the system encoding.

It would make more sense to use UTF-8 unconditionally. MUAs have been able to consume UTF-8 for a long time now, and e.g. Gmail and Apple Mail always send UTF-8, so a MUA unable to ingest UTF-8 in unable to deal with email from the most popular MUAs.

These days, making an effort to use a legacy encoding for outgoing email is more likely to cause compatibility problems than fix them, so using a legacy encoding (i.e. anything but UTF-8) for outgoing email doesn't make sense.

(I came here due to a [report](https://bugzilla.mozilla.org/show_bug.cgi?id=820767#c14) that at least some old version of JavaMail emits pre-`java.nio` Java encoding names (e.g. `ISO8859_1` instead of `iso-8859-1`), which is incompatible with clients that implement [Encoding Standard](https://encoding.spec.whatwg.org/)-compliant label resolution, such as Thunderbird. It's unclear to me if it's still possible for JavaMail to emit pre-`java.nio` names.)

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 mail/src/main/java/javax/mail/internet/MimeUtility.java at getDefaultMIMECharset(), which reads a system property and otherwise uses the system encoding. Trace the callers and existing tests, then verify whether the method can return legacy Java charset names. Done means the default behavior and compatibility impact are settled and covered by the relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
internationalization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.