mime
mime copied to clipboard
Ignore parameters which don't have a = following their name
Per https://mimesniff.spec.whatwg.org/#parse-a-mime-type it ignores the invalid parameters instead of failing to parse the mime type.
mime 0.2 did the right thing but mime 0.3 returns Err(FromStrError { inner: MissingEqual })
Sigh, the problem with media types is that there are literally a trillion specs that say different things: https://tools.ietf.org/html/rfc7231#section-3.1.1.1
Yeah, I know... Unfortunately this makes some wpt tests fail as they rely on the behavior specified in the whatwg spec (sending stuff with "text/css;blah" as Content-type).
Does RFC 7231 specify how to deal with header values that do not match the expected grammar? Does it mandate dropping the entire header, or is that v.s. within-header-value error recovery unspecified?
It does not seem like behavior was specified for errors, only grammar is specified. I'm not set on it following what 7231 says, I was just crying that it's hard to remember which spec to follow.
assert_eq!( Err(MultipartError::ParseContentType) ,"multipart/form-data; boundary=----WebKitFormBoundaryqFrxd8432dXMhW6i==".parse::<mime::Mime>());
assert_eq!( Ok(ct) ,"multipart/form-data; boundary=----WebKitFormBoundaryqFrxd8432dXMhW6i".parse::<mime::Mime>());