jakartaee / jakartaee/mail-api

Error parsing email attachment name

Open
#586 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
285
Forks
109
Avg merge
15h 19m
Merged PRs (30d)
1

Description

**Describe the bug**
I found a problem parsing the name of an email attachment. If I open the same email in outlook or thunderbird the attachment name is shown correctly. Also tested with an RFC 2047 decoder and works OK.

**To Reproduce**
Send an email with an attachment whose name is encoded in the following way:

```
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;
name="=?iso-8859-1?Q?Preparaci=F3n_de_puesto_de_trabajo_Sofia_Cafaro_-_Altenix_?=
=?iso-8859-1?Q?BC.lsx?="
Content-Description:
=?iso-8859-1?Q?Preparaci=F3n_de_puesto_de_trabajo_Sofia_Cafaro_-_Altenix_?=
=?iso-8859-1?Q?BC.xlsx?=
Content-Disposition: attachment;
filename="=?iso-8859-1?Q?Preparaci=F3n_de_puesto_de_trabajo_Sofia_Cafaro_-_Altenix_?=
=?iso-8859-1?Q?BC.xlsx?="; size=69949;
creation-date="Tue, 19 Oct 2021 18:50:44 GMT";
modification-date="Tue, 19 Oct 2021 18:50:44 GMT"
Content-Transfer-Encoding: base64
```

**Expected behavior**
The attachment name should be `Preparación de puesto de trabajo Sofia Cafaro - Altenix BC.xlsx` but the api shows it as `=?iso-8859-1?Q?Preparaci=F3n_de_puesto_de_trabajo_Sofia_Cafaro_-_Altenix_?= =?iso-8859-1?Q?BC.xlsx?=`

**Version tested:**
- 1.6.7
- Java 8
- CentOS Linux release 7.7.1908

**Mail server:**
- Protocol being used: IMAP
- Vendor/product: The email was generated by microsoft outlook

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported IMAP message with the supplied MIME headers and compare the API's attachment-name result with the RFC 2047 decoder output. Trace the Java mail API's attachment filename parsing entry point; done means the expected decoded filename is returned for this sample and the case is covered by a regression test.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.