Skip to content

Commit

Permalink
Only support UTF-8 for the urlencoded parser
Browse files Browse the repository at this point in the history
Fixes #84.
  • Loading branch information
annevk committed Jan 6, 2017
1 parent 4617e33 commit d743575
Showing 1 changed file with 8 additions and 29 deletions.
37 changes: 8 additions & 29 deletions url.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2223,27 +2223,18 @@ sequences. Unfortunately the format is in widespread use due to the prevalence o

<h3 id=urlencoded-parsing><code>application/x-www-form-urlencoded</code> parsing</h3>

<p class="note no-backref">The features provided by the
<a lt="urlencoded parser"><code>application/x-www-form-urlencoded</code> parser</a> are mainly
relevant for server-oriented implementations. A browser-based implementation only needs what the
<a lt="urlencoded string parser"><code>application/x-www-form-urlencoded</code> string parser</a>
requires.
<p class="note no-backref">A legacy server-oriented implementation might have to support
<a for=/>encodings</a> other than <a>UTF-8</a> as well as have special logic for tuples of which the
name is `<code>_charset</code>`. Such logic is not described here as only <a>UTF-8</a> is
conforming.

<p>The
<dfn export id=concept-urlencoded-parser lt='urlencoded parser'><code>application/x-www-form-urlencoded</code> parser</dfn>
takes a byte sequence <var>input</var>, optionally with an <a for=/>encoding</a>
<var>encoding override</var>, and optionally with a <i>use _charset_ flag</i>, and then runs these
steps:
takes a byte sequence <var>input</var>, and then runs these steps:

<ol>
<li><p>Let <var>encoding</var> be <a>UTF-8</a>.

<li><p>If <var>encoding override</var> is given, set <var>encoding</var> to
<var>encoding override</var>.

<li>
<p>If <var>encoding</var> is not <a>UTF-8</a> and <var>input</var> contains bytes that are not
<a>ASCII bytes</a>, return failure.
<p>If <var>input</var> contains bytes that are not <a>ASCII bytes</a>, then return failure.

<p class="note no-backref">This can only happen if <var>input</var> was not generated through the
<a lt='urlencoded serializer'>serializer</a> or {{URLSearchParams}}.
Expand Down Expand Up @@ -2277,18 +2268,6 @@ steps:
<li><p>Replace any `<code>+</code>` in <var>name</var> and
<var>value</var> with 0x20.

<li>
<p>If <i>use _charset_ flag</i> is set and <var>name</var> is `<code>_charset_</code>`, run
these substeps:

<ol>
<li><p>Let <var>result</var> be the result of <a>getting an encoding</a> for <var>value</var>,
<a lt="UTF-8 decode without BOM">decoded</a>.

<li><p>If <var>result</var> is not failure, unset <i>use _charset_ flag</i> and set
<var>encoding</var> to <var>result</var>.
</ol>

<li><p>Add a tuple consisting of <var>name</var> and <var>value</var> to <var>tuples</var>.
</ol>

Expand All @@ -2297,8 +2276,8 @@ steps:

<li><p>For each name-value tuple in <var>tuples</var>, append a name-value tuple to
<var>output</var> where the new name and value appended to <var>output</var> are the result of
running <a>decode</a> on the <a lt="percent decode">percent decoding</a> of the name and value from
<var>tuples</var>, respectively, using <var>encoding</var>.
running <a>UTF-8 decode without BOM</a> on the <a lt="percent decode">percent decoding</a> of the
name and value from <var>tuples</var>, respectively, using <var>encoding</var>.

<li><p>Return <var>output</var>.
</ol>
Expand Down

0 comments on commit d743575

Please sign in to comment.