It seems that multiple values not enclosed by quotes fail to parse. Strings with multiple values enclosed in quotes seem to work, such as "video/ogg; codecs="vorbis, theora"".
The last one in that list looks like a different problem, maybe empty values being rejected?
I extracted these strings from Firefox's media playback "canplaytype" unit tests, they're representative of the types of strings you find on the wider Internet.
Below is my full test, with all Firefox's media playback "canplaytype" tests' MIME types strings, it prints the failed cases. I'd expect these to parse successfully, though some of the values are silly.
extern crate mime;
use mime::Mime;
use std::str::FromStr;
fn main() {
let test_cases = [
"application/dash+xml",
"application/dash+xml; codecs=vorbis",
"application/dash+xml; codecs=vorbis",
"application/dash+xml; codecs=vorbis,vp8",
"application/dash+xml; codecs=vorbis,vp8.0",
"application/dash+xml; codecs=\"vorbis,vp8\"",
"application/dash+xml; codecs=\"vorbis,vp8.0\"",
"application/dash+xml; codecs=\"vp8, vorbis\"",
"application/dash+xml; codecs=\"vp8.0, vorbis\"",
"application/dash+xml; codecs=vp8",
"application/dash+xml; codecs=vp8.0",
"application/dash+xml; codecs=xyz",
"application/dash+xml; codecs=xyz,vorbis",
"application/dash+xml; codecs=vorbis,xyz",
"application/dash+xml; codecs=xyz,vp8.0",
"application/dash+xml; codecs=vp8.0,xyz",
"video/ogg",
"audio/ogg",
"application/ogg",
"audio/ogg; codecs=vorbis",
"video/ogg; codecs=vorbis",
"video/ogg; codecs=vorbis,theora",
"video/ogg; codecs=\"vorbis, theora\"",
"video/ogg; codecs=theora",
"audio/ogg; codecs=opus",
"audio/ogg; codecs=opus",
"video/ogg; codecs=xyz",
"video/ogg; codecs=xyz,vorbis",
"video/ogg; codecs=vorbis,xyz",
"audio/wave",
"audio/wav",
"audio/x-wav",
"audio/x-pn-wav",
"audio/wave; codecs=",
"audio/wave; codecs=1",
"audio/wave; codecs=6",
"audio/wave; codecs=7",
"audio/wave; codecs=",
"audio/wave; codecs=\"\"",
"audio/wave; codecs=0",
"audio/wave; codecs=2",
"audio/wave; codecs=xyz,1",
"audio/wave; codecs=1,xyz",
"audio/wave; codecs=\"xyz, 1\"",
"audio/wave; codecs=\"0, 1,\"",
"video/webm",
"audio/webm",
"video/webm; codecs=xyz",
"video/webm; codecs=xyz,vorbis",
"video/webm; codecs=vorbis,xyz",
"video/mp4; codecs=\"a,b\"; width=1024; Height=768; FrameRate=60; BITRATE=100000",
"Message/Partial; number=2; total=3; id=\"[email protected]\"",
"video/mp4",
"video/x-m4v",
"audio/mp4",
"audio/x-m4a",
"audio/aac",
"audio/aacp",
"video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"",
"video/mp4; codecs=\"avc1.42E01E, mp3\"",
"video/mp4; codecs=\"avc1.42001E, mp4a.40.2\"",
"video/mp4; codecs=\"avc1.58A01E, mp4a.40.2\"",
"video/mp4; codecs=\"avc1.4D401E, mp4a.40.2\"",
"video/mp4; codecs=\"avc1.4D401F, mp4a.40.2\"",
"video/mp4; codecs=\"avc1.4D4028, mp4a.40.2\"",
"video/mp4; codecs=\"avc1.64001E, mp4a.40.2\"",
"video/mp4; codecs=\"avc1.64001F, mp4a.40.2\"",
"video/mp4; codecs=\"avc1.42E01E\"",
"video/mp4; codecs=\"avc1.42001E\"",
"video/mp4; codecs=\"avc1.58A01E\"",
"video/mp4; codecs=\"avc1.4D401E\"",
"video/mp4; codecs=\"avc1.64001F\"",
"audio/mp4; codecs=\"mp4a.40.2\"",
"audio/mp4; codecs=mp4a.40.2",
"audio/x-m4a; codecs=\"mp4a.40.2\"",
"audio/x-m4a; codecs=mp4a.40.2",
"audio/mp4; codecs=\"mp4a.40.5\"",
"audio/mp4; codecs=mp4a.40.5",
"audio/x-m4a; codecs=\"mp4a.40.5\"",
"audio/x-m4a; codecs=mp4a.40.5",
"audio/mp4; codecs=\"mp4a.40.29\"",
"audio/mp4; codecs=\"opus\"",
"audio/mp4; codecs=opus",
"audio/mp4; codecs=\"flac\"",
"audio/mp4; codecs=flac",
"audio/mpeg",
"audio/mp3",
"audio/mpeg; codecs=\"mp3\"",
"audio/mpeg; codecs=mp3",
"audio/mp3; codecs=\"mp3\"",
"audio/mp3; codecs=mp3",
"video/mp4; codecs=vp9",
"video/mp4; codecs=\"vp9\"",
"video/mp4; codecs=\"vp9.0\"",
"audio/m4a",
"video/m4v",
"audio/mp4; codecs=\"mp4a.40.2,\"",
];
for test_case in test_cases.iter() {
match Mime::from_str(test_case) {
Ok(_) => (),
Err(_) => println!("{}", test_case),
};
}
}