Skip to content

Commit

Permalink
Clean up language around form submission and URLs
Browse files Browse the repository at this point in the history
Also fix a bigger issue where we have an Otherwise clause without a
leading If clause. Pass encoding always as parameter.
  • Loading branch information
annevk authored and zcorpan committed May 27, 2016
1 parent e2d80d9 commit 69ea9df
Showing 1 changed file with 43 additions and 71 deletions.
114 changes: 43 additions & 71 deletions source
Expand Up @@ -13915,9 +13915,9 @@ people expect to have work and what is necessary.
in the <span data-x="attr-meta-http-equiv-content-type">Encoding declaration state</span>.</p>

<p class="note">A character encoding declaration is required (either in the <span
data-x="Content-Type">Content-Type metadata</span> or explicitly in the file) even if the encoding
is US-ASCII, because a character encoding is needed to process non-ASCII characters entered by the
user in forms, in URLs generated by scripts, and so forth.</p>
data-x="Content-Type">Content-Type metadata</span> or explicitly in the file) even when all
characters are in the ASCII range, because a character encoding is needed to process non-ASCII
characters entered by the user in forms, in URLs generated by scripts, and so forth.</p>

<p>If the document is <span>an <code>iframe</code> <code data-x="attr-iframe-srcdoc">srcdoc</code>
document</span>, the document must not have a <span>character encoding declaration</span>. (In
Expand Down Expand Up @@ -54424,6 +54424,9 @@ fur
<li><p>Let <var>form data set</var> be the result of <span>constructing the form data
set</span> for <var>form</var> in the context of <var>submitter</var>.</p></li>

<li><p>Let <var>encoding</var> be the result of <span>picking an encoding for the
form</span>.</p>

<li><p>Let <var>action</var> be the <var>submitter</var> element's <span
data-x="concept-fs-action">action</span>.</p></li>

Expand Down Expand Up @@ -54572,25 +54575,22 @@ fur
<dt><dfn data-x="submit-mutate-action">Mutate action URL</dfn>
<dd>

<p>Let <var>query</var> be the result of encoding the <var>form data
set</var> using the <span><code data-x="">application/x-www-form-urlencoded</code> encoding
algorithm</span>, interpreted as a US-ASCII string.</p>
<p>Let <var>query</var> be the result of running the <span><code
data-x="">application/x-www-form-urlencoded</code> encoding algorithm</span> with <var>form
data set</var> and <var>encoding</var>, interpreted as a US-ASCII string.</p>

<p>Set <var>parsed action</var>'s <span data-x="concept-url-query">query</span>
component to <var>query</var>.</p>

<p>Let <var>destination</var> be a new <span>URL</span> formed by applying the
<span data-x="concept-url-serialiser">URL serialiser</span> algorithm to <var>parsed action</var>.</p>

<p><span>Plan to navigate</span> to <var>destination</var>.</p>
<p><span>Plan to navigate</span> to <var>parsed action</var>.</p>

</dd>

<dt><dfn data-x="submit-body">Submit as entity body</dfn>
<dd>

<p>Let <var>entity body</var> be the result of encoding the <var>form data
set</var> using the <span>appropriate form encoding algorithm</span>.</p>
<p>Let <var>entity body</var> be the result of running the <span>appropriate form encoding
algorithm</span> with <var>form data set</var> and <var>encoding</var>.</p>

<p>Let <var>MIME type</var> be determined as follows:</p>

Expand All @@ -54617,15 +54617,10 @@ fur

</dl>

<!--<p>If <var>method</var> is anything but (GET or) POST, and the
<span>origin</span> of <var>action</var> is not the <span>same origin</span> as that
of <var>form document</var>, then abort these steps.</p> [or do CORS] (this is
commented out since only POST can trigger this now, and that's historically unrestricted)-->

<p>Otherwise, <span>plan to navigate</span> to a new <span
data-x="concept-request">request</span> whose <span data-x="concept-request-url">url</span> is
<var>action</var>, <span data-x="concept-request-method">method</span> is <var>method</var>,
<span data-x="concept-request-header-list">header list</span> consists of `<code
<p><span>Plan to navigate</span> to a new <span data-x="concept-request">request</span> whose
<span data-x="concept-request-url">url</span> is <var>parsed action</var>, <span
data-x="concept-request-method">method</span> is <var>method</var>, <span
data-x="concept-request-header-list">header list</span> consists of `<code
data-x="">Content-Type</code>`/<var>MIME type</var>, and <span
data-x="concept-request-body">body</span> is <var>entity body</var>.</p>

Expand All @@ -54634,55 +54629,48 @@ fur
<dt><dfn data-x="submit-get-action">Get action URL</dfn>
<dd>

<p><span>Plan to navigate</span> to <var>action</var>.</p>
<p><span>Plan to navigate</span> to <var>parsed action</var>.</p>

<p class="note">The <var>form data set</var> is discarded.</p>

</dd>

<dt><dfn data-x="submit-mailto-headers">Mail with headers</dfn>
<dd>

<p>Let <var>headers</var> be the resulting encoding the <var>form data
set</var> using the <span><code data-x="">application/x-www-form-urlencoded</code> encoding
algorithm</span>, interpreted as a US-ASCII string.</p>
<p>Let <var>headers</var> be the result of running the <span><code
data-x="">application/x-www-form-urlencoded</code> encoding algorithm</span> with <var>form
data set</var> and <var>encoding</var>, interpreted as a US-ASCII string.</p>

<p>Replace occurrences of U+002B PLUS SIGN characters (+) in <var>headers</var> with
the string "<code data-x="">%20</code>".</p>

<p>Let <var>destination</var> consist of all the characters from the first character
in <var>action</var> to the character immediately before the first U+003F QUESTION
MARK character (?), if any, or the end of the string if there are none.</p>

<p>Append a single U+003F QUESTION MARK character (?) to <var>destination</var>.</p>

<p>Append <var>headers</var> to <var>destination</var>.</p>

<p><span>Plan to navigate</span> to <var>destination</var>.</p>
<p>Set <var>parsed action</var>'s <span data-x="concept-url-query">query</span> to
<var>headers</var>.</p>

<p><span>Plan to navigate</span> to <var>parsed action</var>.</p>
</dd>

<dt><dfn data-x="submit-mailto-body">Mail as body</dfn>
<dd>

<p>Let <var>body</var> be the resulting of encoding the <var>form data
set</var> using the <span>appropriate form encoding algorithm</span> and then <span
<p>Let <var>body</var> be the resulting of running the <span>appropriate form encoding
algorithm</span> with <var>form data set</var> and <var>encoding</var>, and then <span
data-x="percent encode">percent encoding</span> all the bytes in the resulting byte string
that, when interpreted as US-ASCII, are not characters in the URL <span>default encode
set</span>. <ref spec=URL></p>

<p>Let <var>destination</var> have the same value as <var>action</var>.</p>

<p>If <var>destination</var> does not contain a U+003F QUESTION MARK character (?),
append a single U+003F QUESTION MARK character (?) to <var>destination</var>.
Otherwise, append a single U+0026 AMPERSAND character (&amp;).</p>
<p>If <var>parsed action</var>'s <span data-x="concept-url-query">query</span> is null, then
set it to the empty string.

<p>Append the string "<code data-x="">body=</code>" to <var>destination</var>.</p>
<p>If <var>parsed action</var>'s <span data-x="concept-url-query">query</span> is not the
empty string, then append a single U+0026 AMPERSAND character (&amp;) to it.

<p>Append <var>body</var>, interpreted as a US-ASCII string, to <var>destination</var>.</p>
<p>Append "<code data-x="">body=</code>" to <var>parsed action</var>'s <span
data-x="concept-url-query">query</span>.</p>

<p><span>Plan to navigate</span> to <var>destination</var>.</p>
<p>Append <var>body</var>, interpreted as a US-ASCII string, to <var>parsed action</var>'s
<span data-x="concept-url-query">query</span>.</p>

<p><span>Plan to navigate</span> to <var>parsed action</var>.</p>
</dd>


Expand Down Expand Up @@ -55008,14 +54996,12 @@ fur

<div w-nodev>

<p id="application-x-www-form-urlencoded-encoding-algorithm">The <dfn><code data-x="">application/x-www-form-urlencoded</code> encoding algorithm</dfn> is as
follows:</p>
<p id="application-x-www-form-urlencoded-encoding-algorithm">The <dfn><code
data-x="">application/x-www-form-urlencoded</code> encoding algorithm</dfn>, given a <var>form
data set</var> and <var>encoding</var>, is as follows:</p>

<ol>

<li><p>Let <var>encoding</var> be the result of <span>picking an encoding for the
form</span>.</p>

<li><p>Let <var>serialized</var> be the result of running the
<span><code>application/x-www-form-urlencoded</code> serializer</span> given <var>form data
set</var> and <var>encoding</var>.</p></li>
Expand All @@ -55035,28 +55021,17 @@ fur

<!-- NOTE: This algorithm is also used by the XHR spec -->

<p>The <dfn><code>multipart/form-data</code> encoding algorithm</dfn> is as follows:</p>
<p>The <dfn><code>multipart/form-data</code> encoding algorithm</dfn>, given a <var>form data
set</var> and <var>encoding</var>, is as follows:</p>

<ol>

<!-- the first few steps of this are the same as in the previous section -->

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

<li>

<p>If the algorithm was invoked with an explicit character encoding, let the selected character
encoding be that encoding. (This algorithm is used by other specifications, which provide an
explicit character encoding to avoid the dependency on the <code>form</code> element described
in the next paragraph.)</p>

<p>Otherwise, let the selected character encoding be the result of <span>picking an encoding for
the form</span>.</p>

</li>

<li><p>Let <var>charset</var> be the <span data-x="encoding name">name</span> of the
selected <span data-x="encoding">character encoding</span>.</p></li>
<li><p>Let <var>charset</var> be the <span data-x="encoding name">name</span> of
<var>encoding</var>.</p></li>

<li>

Expand Down Expand Up @@ -55119,20 +55094,17 @@ fur
spec=RFC7578></p>



<h5>Plain text form data</h5>

<div w-nodev>

<p>The <dfn><code data-x="">text/plain</code> encoding algorithm</dfn> is as follows:</p>
<p>The <dfn><code data-x="">text/plain</code> encoding algorithm</dfn>, given a <var>form data
set</var> and <var>encoding</var>, is as follows:</p>

<ol>

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

<li><p>Let <var>encoding</var> be the result of <span>picking an encoding for the
form</span>.</p>

<li><p>Let <var>charset</var> be the <span data-x="encoding name">name</span> of
<var>encoding</var>.</p></li>

Expand Down

0 comments on commit 69ea9df

Please sign in to comment.