Closed
Description
[This is a duplicate proposal of #28618, but it's closed due to Timed out in state WaitingForInfo.
and doesn't accept further discussion.]
Some mail user agent (MUA) (incorrectly) generates mail header with duplicate parameter names, this is the one i received recently (duplicate boundary
):
Content-Type: multipart/alternative; boundary="----RTIR0GV26TDW15Q5CVX979LBL6XN18"; boundary="----RTIR0GV26TDW15Q5CVX979LBL6XN18"
Golang standard library mime.ParseMediaType()
does not allow duplicate media parameters so it is impossible to parse such a header (it returns error mime: duplicate parameter name
).
I suggest making the mime.ParseMediaType()
function more tolerant to such errors, for example, just use the first value and ignore the rest. At least it should not stop the execution if duplicate parameters have the same value.
See also:
- proposal: mime: handling duplicate media parameters #28618, @xeruf reported similar mail header:
Content-Type: text/html; charset=utf-8; charset=UTF-8
- mime: bypassing multi-boundary check via Parameter Value Continuations #47602, @Xym01 reported similar http header:
Content-Type: multipart/form-data;boundary="boundary";boundary="another-boundary"