Skip to content
Permalink
Browse files

Clean up language around form submission and URLs

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 69ea9df17bf1d7d70a2014c6d2aaf16670683feb
Showing with 43 additions and 71 deletions.
  1. +43 −71 source
114 source
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
<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>

<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>


</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>

<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>



<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>

<!-- 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>

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>

0 comments on commit 69ea9df

Please sign in to comment.
You can’t perform that action at this time.