Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "parse a MIME type" to check validity. #105

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 42 additions & 6 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,48 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/#
<h4 id='mime-type'>MIME types</h4>

<p>
In the context of this specification, a MIME type is also called content
type. A <dfn>valid media MIME type</dfn> is a string that is a <a>valid
MIME type</a> per [[mimesniff]]. If the MIME type does not imply a
codec, the string MUST also have one and only one parameter that is
named <code>codecs</code> with a value describing a single media codec.
Otherwise, it MUST contain no parameters.
To check if a string <var>mimeString</var> is a <dfn>valid media MIME
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be named something else more specific for this specification, to avoid confusion with the one from the MIME Sniff spec.

type</dfn>, the following steps MUST be run:
<ul>
<li>
Let <var>parsedMime</var> be the result of running the <a>parse a
MIME type</a> [[mimesniff]] algorithm with <var>mimeString</var>.
</li>
<li>
If the value of <var>parsedMime</var> is <code>failure</code>,
return <code>false</code> and abort these steps.
</li>
<li>
If the combined <code>type</code> and <code>subtype</code> members
of <var>parsedMime</var> imply a single media codec, run these
substeps:
<ul>
<li>
If the <code>parameters</code> member of <var>parsedMime</var>
is not empty, return <code>false</code> and abort these steps.
</li>
<li>Otherwise, return <code>true</code>.</li>
</ul>
</li>
<li>
Otherwise run the following substeps:
<ul>
<li>
If the <code>parameters</code> member of <var>parsedMime</var>
does not contain a single key named "codecs", return
<code>false</code> and abort these steps.
</li>
<li>
If the value of <code>parsedMime.parameters["codecs"]</code>
does not describe a single media codec, return
<code>false</code> and abort these steps.
</li>
<li>
Otherwise, return true.
</li>
</ul>
</li>
</ul>
</p>

<p>
Expand Down