fix(GODT-2966): Allow permissive parsing of MediaType parameters for import.

This commit is contained in:
Romain Le Jeune
2023-10-09 15:14:51 +00:00
parent d7dadd7578
commit 5c7e4e04f9
7 changed files with 110 additions and 61 deletions

View File

@ -256,6 +256,10 @@ 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) (mediatype string, params map[string]string, err error) {
v, _ = changeEncodingAndKeepLastParamDefinition(v)
decoded, err := DecodeHeader(v)
if err != nil {
return "", nil, err
}
v, _ = changeEncodingAndKeepLastParamDefinition(decoded)
return mime.ParseMediaType(v)
}