emersion / emersion/go-message
RFC2047 encoded-words as content-transfer-encoding value
- Dominant language
- Go
- Stars
- 458
- Forks
- 129
- PR merge metrics
- No merged PRs in 30d
Description
There exist messages in the wild (notably, some originating from mailbox.org's automated mailer e.g. due to payments) in which the `content-transfer-encoding` presents as an RFC2047 encoded-word. For instance, here is a (redacted) example:
```
To: user@mailbox.org
MIME-Version: 1.0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: =?utf-8?Q?8bit?=
From: =?utf-8?Q?mailbox.org?=
Lieber Kunde,
... stuff in german ...
```
go-message cannot handle such messages.
One "hacky" solution is to simply pass the encoded word through the header decoder, as in this patch:
```patch
diff --git a/entity.go b/entity.go
index 99e69c8..fe13d91 100644
--- a/entity.go
+++ b/entity.go
@@ -35,8 +35,9 @@ func New(header Header, body io.Reader) (*Entity, error) {
// e.g. "quoted-printable". So we just ignore it for multipart.
// See https://github.com/emersion/go-message/issues/48
if !strings.HasPrefix(mediaType, "multipart/") {
- enc := header.Get("Content-Transfer-Encoding")
- if decoded, encErr := encodingReader(enc, body); encErr != nil {
+ if enc, decErr := decodeHeader(header.Get("Content-Transfer-Encoding")); decErr != nil {
+ err = UnknownEncodingError{decErr}
+ } else if decoded, encErr := encodingReader(enc, body); encErr != nil {
err = UnknownEncodingError{encErr}
} else {
body = decoded
```
Contributor guide
Assessment
This issue has not been assessed yet.