forked from Silverfish/proton-bridge
chore(GODT-3010): Log MimeType parsing issue.
This commit is contained in:
committed by
Romain Le Jeune
parent
dc584ea29b
commit
4ea161f7ad
@ -255,11 +255,17 @@ 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.
|
// ParseMediaType from MIME doesn't support RFC2231 for non asci / utf8 encodings so we have to pre-parse it.
|
||||||
func ParseMediaType(v string) (mediatype string, params map[string]string, err error) {
|
func ParseMediaType(v string) (string, map[string]string, error) {
|
||||||
decoded, err := DecodeHeader(v)
|
decoded, err := DecodeHeader(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logrus.WithField("value", v).WithError(err).Error("Media Type parsing error.")
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
v, _ = changeEncodingAndKeepLastParamDefinition(decoded)
|
v, _ = changeEncodingAndKeepLastParamDefinition(decoded)
|
||||||
return mime.ParseMediaType(v)
|
mediatype, params, err := mime.ParseMediaType(v)
|
||||||
|
if err != nil {
|
||||||
|
logrus.WithField("value", v).WithError(err).Error("Media Type parsing error.")
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
return mediatype, params, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user