1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-06-11 15:19:02 +02:00

Add quoted-printable decoding to smtp server

Some e-mails are sent using quoted-printable encoding [0], resulting in
notifications with weird characters.

This commit adds support for this encoding, resulting in the following:

**Before**
```
A
=3D=3D=3D=3D=3D
B
=3D=3D=3D=3D=3D
C
```

**After**
```
A
=====
B
=====
C
```

[0] https://www.rfc-editor.org/rfc/rfc2045.html
This commit is contained in:
Guillaume Taquet Gasperini 2023-05-08 10:31:06 +02:00
parent 5bc51eefd9
commit 5b8520b4e0
2 changed files with 80 additions and 0 deletions

View file

@ -9,6 +9,7 @@ import (
"io"
"mime"
"mime/multipart"
"mime/quotedprintable"
"net"
"net/http"
"net/http/httptest"
@ -265,6 +266,8 @@ func readMultipartMailBody(body io.Reader, params map[string]string, depth int)
func readPlainTextMailBody(reader io.Reader, transferEncoding string) (string, error) {
if strings.ToLower(transferEncoding) == "base64" {
reader = base64.NewDecoder(base64.StdEncoding, reader)
} else if strings.ToLower(transferEncoding) == "quoted-printable" {
reader = quotedprintable.NewReader(reader)
}
body, err := io.ReadAll(reader)
if err != nil {