Skip to content

Commit

Permalink
Encode documents using utf-8. https://www.w3.org/Bugs/Public/show_bug…
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Sep 26, 2013
1 parent 4013918 commit 8f95fa0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 76 deletions.
58 changes: 19 additions & 39 deletions Overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<p><a class="logo" href="//www.whatwg.org/"><img alt="WHATWG" height="100" src="//resources.whatwg.org/logo-xhr.svg" width="100"></a>
<h1 class="head" id="xmlhttprequest-ls">XMLHttpRequest</h1>
<h2 class="no-num no-toc" id="living-standard-—-last-updated-13-september-2013">Living Standard — Last Updated 13 September 2013</h2>
<h2 class="no-num no-toc" id="living-standard-—-last-updated-26-september-2013">Living Standard — Last Updated 26 September 2013</h2>

<dl>
<dt>This Version:
Expand Down Expand Up @@ -36,7 +36,7 @@ <h2 class="no-num no-toc" id="living-standard-—-last-updated-13-september-2013
<p class="copyright"><a href="http://creativecommons.org/publicdomain/zero/1.0/" rel="license"><img alt="CC0" src="http://i.creativecommons.org/p/zero/1.0/80x15.png"></a>
To the extent possible under law, the editor has waived all copyright and
related or neighboring rights to this work. In addition, as of
13 September 2013, the editor has made this specification available
26 September 2013, the editor has made this specification available
under the
<a href="http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0" rel="license">Open Web Foundation Agreement Version 1.0</a>,
which is available at
Expand Down Expand Up @@ -1017,7 +1017,6 @@ <h4 id="the-send()-method"><span class="secno">4.6.6 </span>The <code title="">s
null, and then follow these rules, depending on <var title="">data</var>:

<dl class="switch">

<dt id="dom-XMLHttpRequest-send-ArrayBufferView"><code class="external"><a href="http://www.khronos.org/registry/typedarray/specs/latest/#6">ArrayBufferView</a></code>
<dd><p>Let the <a href="#request-entity-body">request entity body</a> be the raw data
represented by <var title="">data</var>.</dd>
Expand All @@ -1034,53 +1033,34 @@ <h4 id="the-send()-method"><span class="secno">4.6.6 </span>The <code title="">s
represented by <var>data</var>.
</dd>


<dt id="dom-XMLHttpRequest-send-document"><a class="external" href="http://dom.spec.whatwg.org/#concept-document" title="concept-document">document</a>
<dd>
<p>Let <var title="">encoding</var> be the
<a class="external" href="http://dom.spec.whatwg.org/#concept-document-encoding" title="concept-document-encoding">encoding</a>
of <var title="">data</var>. If <var title="">encoding</var> is
<a class="external" href="http://encoding.spec.whatwg.org/#utf-16le">utf-16le</a> or
<a class="external" href="http://encoding.spec.whatwg.org/#utf-16be">utf-16be</a>, set
<var title="">encoding</var> to
<a class="external" href="http://encoding.spec.whatwg.org/#utf-8">utf-8</a>.

<p>If <var title="">data</var> is an
<a class="external" href="http://dom.spec.whatwg.org/#html-document">HTML document</a>, let
<var>mime type</var> be "<code>text/html</code>", or let
<var>mime type</var> be "<code>application/xml</code>" otherwise. Then
append "<code>;charset=<var>encoding</var></code>" to
<p>Let <var>encoding</var> be "<code title="">UTF-8</code>".

<p>If <var title="">data</var> is an <a class="external" href="http://dom.spec.whatwg.org/#html-document">HTML document</a>, let
<var>mime type</var> be "<code>text/html</code>", or let <var>mime type</var> be
"<code>application/xml</code>" otherwise. Then append "<code>;charset=UTF-8</code>" to
<var>mime type</var>.

<p><a class="external" href="http://html5.org/specs/dom-parsing.html#concept-serialize" title="concept-serialize">Serialize</a>
<var title="">data</var>, and let the <a href="#request-entity-body">request entity body</a> be the result,
<p>Let the <a href="#request-entity-body">request entity body</a> be <var title="">data</var>,
<a class="external" href="http://domparsing.spec.whatwg.org/#concept-serialize" title="concept-serialize">serialized</a>,
<a class="external" href="http://dev.w3.org/2006/webapi/WebIDL/#dfn-obtain-unicode" title="convert a DOMString to a sequence of Unicode characters">converted to Unicode</a>
and <a class="external" href="http://encoding.spec.whatwg.org/#encode" title="encode">encoded</a> using
encoding <var>encoding</var>. Re-throw any exception this
throws.
and <a class="external" href="http://encoding.spec.whatwg.org/#utf-8-encode" title="utf-8 encode">utf-8 encoded</a>.
Re-throw any exception
<a class="external" href="http://domparsing.spec.whatwg.org/#concept-serialize" title="concept-serialize">serializing</a> throws.

<p class="XXX">Should we only encode as utf-8? What happens in the face
of an <a class="external" href="http://encoding.spec.whatwg.org/#error">error</a>?

<p class="note">In particular, if the document cannot be serialized an
"<code class="external"><a href="http://dom.spec.whatwg.org/#invalidstateerror">InvalidStateError</a></code>" exception is
thrown.

<p class="note">Subsequent changes to the
<a class="external" href="http://dom.spec.whatwg.org/#concept-document" title="concept-document">document</a> have
no effect on what is transferred.
</dd>
<p class="note">If the <var title="">data</var> cannot be
<a class="external" href="http://domparsing.spec.whatwg.org/#concept-serialize" title="concept-serialize">serialized</a> an
"<code class="external"><a href="http://dom.spec.whatwg.org/#invalidstateerror">InvalidStateError</a></code>" exception is thrown.

<dt id="dom-XMLHttpRequest-send-a-string">a string
<dd>
<p>Let <var>encoding</var> be "<code title="">UTF-8</code>".

<p>Let <var>mime type</var> be "<code>text/plain;charset=UTF-8</code>".

<p>Let the <a href="#request-entity-body">request entity body</a> be <var title="">data</var> ,
<a class="external" href="http://encoding.spec.whatwg.org/#encode" title="encode">encoded</a> as
<a class="external" href="http://encoding.spec.whatwg.org/#utf-8">utf-8</a>.
</dd>
<p>Let the <a href="#request-entity-body">request entity body</a> be <var title="">data</var>,
<a class="external" href="http://encoding.spec.whatwg.org/#utf-8-encode" title="utf-8 encode">utf-8 encoded</a>.

<dt id="dom-XMLHttpRequest-send-FormData"><code><a href="#formdata">FormData</a></code>
<dd>
Expand Down Expand Up @@ -1109,7 +1089,7 @@ <h4 id="the-send()-method"><span class="secno">4.6.6 </span>The <code title="">s
<!-- utf-8 implied -->

<p>Let <var>mime type</var> be
"<code title="">application/x-www-form-urlencoded;charset=utf-8</code>.
"<code title="">application/x-www-form-urlencoded;charset=UTF-8</code>.
</dl>

<p>If a <code>Content-Type</code> header is in
Expand Down Expand Up @@ -1715,7 +1695,7 @@ <h4 id="the-abort()-method"><span class="secno">4.6.8 </span>The <code title="">
</ol>

<li>
<p>change the state to <a href="#dom-xmlhttprequest-unsent" title="dom-XMLHttpRequest-UNSENT">UNSENT</a>.
<p>Change the state to <a href="#dom-xmlhttprequest-unsent" title="dom-XMLHttpRequest-UNSENT">UNSENT</a>.

<p class="note">No <code title="event-xhr-readystatechange"><a href="#event-xhr-readystatechange">readystatechange</a></code> event
is dispatched.
Expand Down
54 changes: 17 additions & 37 deletions Overview.src.html
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,6 @@ <h4>The <code title>send()</code> method</h4>
null, and then follow these rules, depending on <var title>data</var>:

<dl class=switch>

<dt id="dom-XMLHttpRequest-send-ArrayBufferView"><code data-anolis-spec=typedarray>ArrayBufferView</code>
<dd><p>Let the <span>request entity body</span> be the raw data
represented by <var title>data</var>.</dd>
Expand All @@ -986,53 +985,34 @@ <h4>The <code title>send()</code> method</h4>
represented by <var>data</var>.
</dd>


<dt id="dom-XMLHttpRequest-send-document"><span data-anolis-spec=dom title=concept-document>document</span>
<dd>
<p>Let <var title>encoding</var> be the
<span data-anolis-spec=dom title=concept-document-encoding>encoding</span>
of <var title>data</var>. If <var title>encoding</var> is
<span data-anolis-spec=encoding>utf-16le</span> or
<span data-anolis-spec=encoding>utf-16be</span>, set
<var title>encoding</var> to
<span data-anolis-spec=encoding>utf-8</span>.

<p>If <var title>data</var> is an
<span data-anolis-spec=dom>HTML document</span>, let
<var>mime type</var> be "<code>text/html</code>", or let
<var>mime type</var> be "<code>application/xml</code>" otherwise. Then
append "<code>;charset=<var>encoding</var></code>" to
<p>Let <var>encoding</var> be "<code title>UTF-8</code>".

<p>If <var title>data</var> is an <span data-anolis-spec=dom>HTML document</span>, let
<var>mime type</var> be "<code>text/html</code>", or let <var>mime type</var> be
"<code>application/xml</code>" otherwise. Then append "<code>;charset=UTF-8</code>" to
<var>mime type</var>.

<p><span data-anolis-spec=domps title=concept-serialize>Serialize</span>
<var title>data</var>, and let the <span>request entity body</span> be the result,
<p>Let the <span>request entity body</span> be <var title>data</var>,
<span data-anolis-spec=domps title=concept-serialize>serialized</span>,
<span data-anolis-spec=webidl title="convert a DOMString to a sequence of Unicode characters">converted to Unicode</span>
and <span data-anolis-spec=encoding title=encode>encoded</span> using
encoding <var>encoding</var>. Re-throw any exception this
throws.
and <span data-anolis-spec=encoding title="utf-8 encode">utf-8 encoded</span>.
Re-throw any exception
<span data-anolis-spec=domps title=concept-serialize>serializing</span> throws.

<p class=XXX>Should we only encode as utf-8? What happens in the face
of an <span data-anolis-spec=encoding>error</span>?

<p class=note>In particular, if the document cannot be serialized an
"<code data-anolis-spec=dom>InvalidStateError</code>" exception is
thrown.

<p class=note>Subsequent changes to the
<span data-anolis-spec=dom title=concept-document>document</span> have
no effect on what is transferred.
</dd>
<p class=note>If the <var title>data</var> cannot be
<span data-anolis-spec=domps title=concept-serialize>serialized</span> an
"<code data-anolis-spec=dom>InvalidStateError</code>" exception is thrown.

<dt id="dom-XMLHttpRequest-send-a-string">a string
<dd>
<p>Let <var>encoding</var> be "<code title>UTF-8</code>".

<p>Let <var>mime type</var> be "<code>text/plain;charset=UTF-8</code>".

<p>Let the <span>request entity body</span> be <var title>data</var> ,
<span data-anolis-spec=encoding title=encode>encoded</span> as
<span data-anolis-spec=encoding>utf-8</span>.
</dd>
<p>Let the <span>request entity body</span> be <var title>data</var>,
<span data-anolis-spec=encoding title="utf-8 encode">utf-8 encoded</span>.

<dt id="dom-XMLHttpRequest-send-FormData"><code>FormData</code>
<dd>
Expand Down Expand Up @@ -1061,7 +1041,7 @@ <h4>The <code title>send()</code> method</h4>
<!-- utf-8 implied -->

<p>Let <var>mime type</var> be
"<code title>application/x-www-form-urlencoded;charset=utf-8</code>.
"<code title>application/x-www-form-urlencoded;charset=UTF-8</code>.
</dl>

<p>If a <code>Content-Type</code> header is in
Expand Down Expand Up @@ -1667,7 +1647,7 @@ <h4>The <code title>abort()</code> method</h4>
</ol>

<li>
<p>change the state to <span title="dom-XMLHttpRequest-UNSENT">UNSENT</span>.
<p>Change the state to <span title="dom-XMLHttpRequest-UNSENT">UNSENT</span>.

<p class=note>No <code title="event-xhr-readystatechange">readystatechange</code> event
is dispatched.
Expand Down

0 comments on commit 8f95fa0

Please sign in to comment.