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

Add a final newline normalization for form payloads #6287

Merged
merged 7 commits into from
May 20, 2021
Merged
Changes from all commits
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
104 changes: 86 additions & 18 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -56061,9 +56061,12 @@ fur
<dl>
<dt><dfn data-x="submit-mutate-action">Mutate action URL</dfn>
<dd>
<p>Let <var>pairs</var> be the result of <span data-x="convert to a list of name-value
pairs">converting to a list of name-value pairs</span> with <var>entry list</var>.</p>

<p>Let <var>query</var> be the result of running the
<span><code>application/x-www-form-urlencoded</code> serializer</span> with <var>entry
list</var> and <var>encoding</var>.</p>
<span><code>application/x-www-form-urlencoded</code> serializer</span> with <var>pairs</var>
and <var>encoding</var>.</p>

<p>Set <var>parsed action</var>'s <span data-x="concept-url-query">query</span>
component to <var>query</var>.</p>
Expand All @@ -56079,9 +56082,12 @@ fur
<dt><code data-x="attr-fs-enctype-urlencoded">application/x-www-form-urlencoded</code></dt>

<dd>
<p>Let <var>pairs</var> be the result of <span data-x="convert to a list of name-value
pairs">converting to a list of name-value pairs</span> with <var>entry list</var>.</p>

<p>Let <var>body</var> be the result of running the
<span><code>application/x-www-form-urlencoded</code> serializer</span> with <var>entry
list</var> and <var>encoding</var>.</p>
<span><code>application/x-www-form-urlencoded</code> serializer</span> with <var>pairs</var>
and <var>encoding</var>.</p>

<p>Set <var>body</var> to the result of <span data-x="UTF-8 encode">encoding</span>
<var>body</var>.</p>
Expand All @@ -56106,8 +56112,11 @@ fur
<dt><code data-x="attr-fs-enctype-text">text/plain</code></dt>

<dd>
<p>Let <var>pairs</var> be the result of <span data-x="convert to a list of name-value
pairs">converting to a list of name-value pairs</span> with <var>entry list</var>.</p>

<p>Let <var>body</var> be the result of running the <span><code data-x="">text/plain</code>
encoding algorithm</span> with <var>entry list</var>.</p>
encoding algorithm</span> with <var>pairs</var>.</p>

<p>Set <var>body</var> to the result of <span data-x="encode">encoding</span>
<var>body</var> using <var>encoding</var>.</p>
andreubotella marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -56133,9 +56142,12 @@ fur

<dt><dfn data-x="submit-mailto-headers">Mail with headers</dfn>
<dd>
<p>Let <var>pairs</var> be the result of <span data-x="convert to a list of name-value
pairs">converting to a list of name-value pairs</span> with <var>entry list</var>.</p>

<p>Let <var>headers</var> be the result of running the
<span><code>application/x-www-form-urlencoded</code> serializer</span> with <var>entry
list</var> and <var>encoding</var>.</p>
<span><code>application/x-www-form-urlencoded</code> serializer</span> with <var>pairs</var>
and <var>encoding</var>.</p>

<p>Replace occurrences of U+002B PLUS SIGN characters (+) in <var>headers</var> with
the string "<code data-x="">%20</code>".</p>
Expand All @@ -56148,14 +56160,17 @@ fur

<dt><dfn data-x="submit-mailto-body">Mail as body</dfn>
<dd>
<p>Let <var>pairs</var> be the result of <span data-x="convert to a list of name-value
pairs">converting to a list of name-value pairs</span> with <var>entry list</var>.</p>

<p>Switch on <var>enctype</var>:

<dl class="switch">
<dt><code data-x="attr-fs-enctype-text">text/plain</code></dt>

<dd>
<p>Let <var>body</var> be the result of running the <span><code data-x="">text/plain</code>
encoding algorithm</span> with <var>entry list</var>.</p>
encoding algorithm</span> with <var>pairs</var>.</p>

<p>Set <var>body</var> to the result of running <span>UTF-8 percent-encode</span> on
<var>body</var> using the <span>default encode set</span>. <ref spec=URL></p>
Expand All @@ -56164,8 +56179,8 @@ fur
<dt>Otherwise</dt>

<dd><p>Let <var>body</var> be the result of running the
<span><code>application/x-www-form-urlencoded</code> serializer</span> with <var>entry
list</var> and <var>encoding</var>.</p></dd>
<span><code>application/x-www-form-urlencoded</code> serializer</span> with <var>pairs</var>
and <var>encoding</var>.</p></dd>
</dl>

<p>If <var>parsed action</var>'s <span data-x="concept-url-query">query</span> is null, then
Expand Down Expand Up @@ -56497,6 +56512,47 @@ fur

</div>

<div w-nodev>

<h5>Converting an entry list to a list of name-value pairs</h5>

<p>The <code>application/x-www-form-urlencoded</code> and <code data-x="text/plain encoding
algorithm">text/plain</code> encoding algorithms take a list of name-value pairs, where the values
must be strings, rather than an entry list where the value can be a <code>File</code>. The
following algorithm performs the conversion.</p>

<p>To <dfn>convert to a list of name-value pairs</dfn> an entry list <var>entry list</var>, run
these steps:</p>

<ol>
<li><p>Let <var>list</var> be an empty <span>list</span> of name-value pairs.</p></li>

<li>
<p><span data-x="list iterate">For each</span> <var>entry</var> of <var>entry list</var>:</p>

<ol>
<li><p>Let <var>name</var> be <var>entry</var>'s name, with every occurrence of U+000D (CR) not
followed by U+000A (LF), and every occurrence of U+000A (LF) not preceded by U+000D (CR),
replaced by a string consisting of U+000D (CR) and U+000A (LF).</p></li>

<li><p>If <var>entry</var>'s value is a <code>File</code> object, then let <var>value</var> be
<var>entry</var>'s value's <code data-x="dom-file-name">name</code>. Otherwise, let
<var>value</var> be <var>entry</var>'s value.</p></li>

<li><p>Replace every occurrence of U+000D (CR) not followed by U+000A (LF), and every occurrence
of U+000A (LF) not preceded by U+000D (CR), in <var>value</var>, by a string consisting of
U+000D (CR) and U+000A (LF).</p></li>

<li><p><span data-x="list append">Append</span> to <var>list</var> a new name-value pair whose
name is <var>name</var> and whose value is <var>value</var>.</p></li>
</ol>
</li>

<li><p>Return <var>list</var>.</p></li>
</ol>

</div>


<h5>URL-encoded form data</h5>

Expand All @@ -56518,6 +56574,21 @@ fur
list</var> and <var>encoding</var>, is as follows:</p>

<ol>
<li>
<p><span data-x="list iterate">For each</span> <var>entry</var> of <var>entry list</var>:</p>

<ol>
<li><p>Replace every occurrence of U+000D (CR) not followed by U+000A (LF), and every
occurrence of U+000A (LF) not preceded by U+000D (CR), in <var>entry</var>'s name, by a string
consisting of a U+000D (CR) and U+000A (LF).</p></li>

<li><p>If <var>entry</var>'s value is not a <code>File</code> object, then replace every
occurrence of U+000D (CR) not followed by U+000A (LF), and every occurrence of U+000A (LF) not
preceded by U+000D (CR), in <var>entry</var>'s value, by a string consisting of a U+000D (CR)
and U+000A (LF).</p></li>
</ol>
</li>

<li>
<p>Return the byte sequence resulting from encoding the <var>entry list</var> using the rules
described by RFC 7578, <cite>Returning Values from Forms: <code
Expand Down Expand Up @@ -56561,24 +56632,21 @@ fur

<div w-nodev>

<p>The <dfn><code data-x="">text/plain</code> encoding algorithm</dfn>, given an <var>entry
list</var>, is as follows:</p>
<p>The <dfn><code data-x="">text/plain</code> encoding algorithm</dfn>, given a list of name-value
pairs <var>pairs</var>, is as follows:</p>

<ol>
<li><p>Let <var>result</var> be the empty string.</p></li>

<li>
<p>For each <span data-x="formdata-entry">entry</span> in <var>entry list</var>:</p>
<p>For each <var>pair</var> in <var>pairs</var>:</p>

<ol>
<li><p>If the entry's value is a <code>File</code> object, then set its value to the
<code>File</code> object's <code data-x="dom-file-name">name</code>.</p></li>

<li><p>Append the entry's name to <var>result</var>.</p></li>
<li><p>Append <var>pair</var>'s name to <var>result</var>.</p></li>

<li><p>Append a single U+003D EQUALS SIGN character (=) to <var>result</var>.</p></li>

<li><p>Append the entry's value to <var>result</var>.</p></li>
<li><p>Append <var>pair</var>'s value to <var>result</var>.</p></li>

<li><p>Append a U+000D CARRIAGE RETURN (CR) U+000A LINE FEED (LF) character pair to <var>result</var>.</p></li>
</ol>
Expand Down