feat(GODT-3193): assume text content type on attachments.
This commit is contained in:
parent
63e272e270
commit
754d80d097
|
@ -552,6 +552,11 @@ func parseAttachment(h message.Header, body []byte) (Attachment, error) {
|
|||
att.Header = mimeHeader
|
||||
mimeType, mimeTypeParams, err := pmmime.ParseMediaType(h.Get("Content-Type"))
|
||||
|
||||
if err == pmmime.EmptyContentTypeErr {
|
||||
mimeType = "text/plain"
|
||||
err = nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return Attachment{}, err
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ import (
|
|||
"golang.org/x/text/encoding/htmlindex"
|
||||
)
|
||||
|
||||
var EmptyContentTypeErr = errors.New("empty content type")
|
||||
|
||||
func init() {
|
||||
rfc822.ParseMediaType = ParseMediaType
|
||||
proton.CharsetReader = CharsetReader
|
||||
|
@ -257,7 +259,7 @@ func DecodeCharset(original []byte, contentType string) ([]byte, error) {
|
|||
// ParseMediaType from MIME doesn't support RFC2231 for non asci / utf8 encodings so we have to pre-parse it.
|
||||
func ParseMediaType(v string) (string, map[string]string, error) {
|
||||
if v == "" {
|
||||
return "", nil, errors.New("empty media type")
|
||||
return "", nil, EmptyContentTypeErr
|
||||
}
|
||||
decoded, err := DecodeHeader(v)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue