This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 20067 - Describe how to parse MIME types
Summary: Describe how to parse MIME types
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: MIME (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: Unsorted
Assignee: Gordon P. Hemsley
QA Contact: sideshowbarker+mimespec
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-23 16:55 UTC by Gordon P. Hemsley
Modified: 2013-05-27 20:59 UTC (History)
1 user (show)

See Also:


Attachments

Description Gordon P. Hemsley 2012-11-23 16:55:34 UTC
Roughly:

type/subtype; name1=value1; name2=value2; ...

(.+)\/(.+)(?:;\s*(?:(.+)\s*(?:=\s*(.*))?)?)*

\1 = type
\2 = subtype
{
\3 = parameter name
\4 = parameter value
}*
Comment 1 Gordon P. Hemsley 2013-05-07 18:37:45 UTC
I added a work-in-progress algorithm for this a few months back:

https://github.com/whatwg/mimesniff/commit/d4a84208820af1e74a8d4176ad6966aa294d9127

http://mimesniff.spec.whatwg.org/#parsing-a-mime-type

But it's been suggested that I use some ABNF and error handling instead, so I might choose to do that in the future.
Comment 2 Gordon P. Hemsley 2013-05-27 20:59:38 UTC
I've made enough changes to the algorithm recently that I think this is reasonably complete. (Problems should go in new bugs.)