mime icon indicating copy to clipboard operation
mime copied to clipboard

Ignore parameters which don't have a = following their name

Open Eijebong opened this issue 6 years ago • 5 comments

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 })

Eijebong avatar Sep 04 '18 13:09 Eijebong

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

seanmonstar avatar Sep 04 '18 16:09 seanmonstar

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).

Eijebong avatar Sep 04 '18 16:09 Eijebong

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?

SimonSapin avatar Sep 04 '18 16:09 SimonSapin

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.

seanmonstar avatar Sep 04 '18 17:09 seanmonstar

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>());

Jekahome avatar Jul 15 '20 14:07 Jekahome