Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[e] (0) Clarify the 'escaping a string' algorithm by expanding it int…
…o a full explanation.

Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=11285

git-svn-id: http://svn.whatwg.org/webapps@5797 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jan 21, 2011
1 parent 354fa02 commit 2333a9b
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 34 deletions.
28 changes: 18 additions & 10 deletions complete.html
Expand Up @@ -84397,15 +84397,7 @@ <h3 id=serializing-html-fragments><span class=secno>12.3 </span>Serializing HTML

<li><p>The result of the algorithm is the string <var title="">s</var>.</li>

</ol><p><dfn id=escapingString>Escaping a string</dfn> (for the
purposes of the algorithm above) consists of replacing any
occurrences of the "<code title="">&amp;</code>" character by the
string "<code title="">&amp;amp;</code>", any occurrences of the
U+00A0 NO-BREAK SPACE character by the string "<code title="">&amp;nbsp;</code>", and, if the algorithm was invoked in
the <i>attribute mode</i>, any occurrences of the "<code title="">"</code>" character by the string "<code title="">&amp;quot;</code>", or if it was not, any occurrences of
the "<code title="">&lt;</code>" character by the string "<code title="">&amp;lt;</code>", any occurrences of the "<code title="">&gt;</code>" character by the string "<code title="">&amp;gt;</code>".</p>

<p class=note>Entity reference nodes are <a href=#entity-references>assumed to be expanded</a> by the user
</ol><p class=note>Entity reference nodes are <a href=#entity-references>assumed to be expanded</a> by the user
agent, and are therefore not covered in the algorithm above.</p>

<p class=note>It is possible that the output of this algorithm, if
Expand All @@ -84425,8 +84417,24 @@ <h3 id=serializing-html-fragments><span class=secno>12.3 </span>Serializing HTML
<a href=#syntax-start-tag title=syntax-start-tag>start tag</a> would imply the end
tag for the <code><a href=#the-p-element>p</a></code>).</p>

<p><dfn id=escapingString>Escaping a string</dfn> (for the
purposes of the algorithm above) consists of running the following
steps:</p>

<ol><li><p>Replace any occurrence of the "<code title="">&amp;</code>"
character by the string "<code title="">&amp;amp;</code>".</li>

<li><p>Replace any occurrences of the U+00A0 NO-BREAK SPACE
character by the string "<code title="">&amp;nbsp;</code>".</li>

<li><p>If the algorithm was invoked in the <i>attribute mode</i>,
replace any occurrences of the "<code title="">"</code>"
character by the string "<code title="">&amp;quot;</code>".</li>

<li><p>If the algorithm was <em>not</em> invoked in the
<i>attribute mode</i>, replace any occurrences of the "<code title="">&lt;</code>" character by the string "<code title="">&amp;lt;</code>", and any occurrences of the "<code title="">&gt;</code>" character by the string "<code title="">&amp;gt;</code>".</li>

<h3 id=parsing-html-fragments><span class=secno>12.4 </span>Parsing HTML fragments</h3>
</ol><h3 id=parsing-html-fragments><span class=secno>12.4 </span>Parsing HTML fragments</h3>

<p>The following steps form the <dfn id=html-fragment-parsing-algorithm>HTML fragment parsing
algorithm</dfn>. The algorithm optionally takes as input an
Expand Down
28 changes: 18 additions & 10 deletions index
Expand Up @@ -80367,15 +80367,7 @@ document.body.appendChild(text);

<li><p>The result of the algorithm is the string <var title="">s</var>.</li>

</ol><p><dfn id=escapingString>Escaping a string</dfn> (for the
purposes of the algorithm above) consists of replacing any
occurrences of the "<code title="">&amp;</code>" character by the
string "<code title="">&amp;amp;</code>", any occurrences of the
U+00A0 NO-BREAK SPACE character by the string "<code title="">&amp;nbsp;</code>", and, if the algorithm was invoked in
the <i>attribute mode</i>, any occurrences of the "<code title="">"</code>" character by the string "<code title="">&amp;quot;</code>", or if it was not, any occurrences of
the "<code title="">&lt;</code>" character by the string "<code title="">&amp;lt;</code>", any occurrences of the "<code title="">&gt;</code>" character by the string "<code title="">&amp;gt;</code>".</p>

<p class=note>Entity reference nodes are <a href=#entity-references>assumed to be expanded</a> by the user
</ol><p class=note>Entity reference nodes are <a href=#entity-references>assumed to be expanded</a> by the user
agent, and are therefore not covered in the algorithm above.</p>

<p class=note>It is possible that the output of this algorithm, if
Expand All @@ -80395,8 +80387,24 @@ document.body.appendChild(text);
<a href=#syntax-start-tag title=syntax-start-tag>start tag</a> would imply the end
tag for the <code><a href=#the-p-element>p</a></code>).</p>

<p><dfn id=escapingString>Escaping a string</dfn> (for the
purposes of the algorithm above) consists of running the following
steps:</p>

<ol><li><p>Replace any occurrence of the "<code title="">&amp;</code>"
character by the string "<code title="">&amp;amp;</code>".</li>

<li><p>Replace any occurrences of the U+00A0 NO-BREAK SPACE
character by the string "<code title="">&amp;nbsp;</code>".</li>

<li><p>If the algorithm was invoked in the <i>attribute mode</i>,
replace any occurrences of the "<code title="">"</code>"
character by the string "<code title="">&amp;quot;</code>".</li>

<li><p>If the algorithm was <em>not</em> invoked in the
<i>attribute mode</i>, replace any occurrences of the "<code title="">&lt;</code>" character by the string "<code title="">&amp;lt;</code>", and any occurrences of the "<code title="">&gt;</code>" character by the string "<code title="">&amp;gt;</code>".</li>

<h3 id=parsing-html-fragments><span class=secno>10.4 </span>Parsing HTML fragments</h3>
</ol><h3 id=parsing-html-fragments><span class=secno>10.4 </span>Parsing HTML fragments</h3>

<p>The following steps form the <dfn id=html-fragment-parsing-algorithm>HTML fragment parsing
algorithm</dfn>. The algorithm optionally takes as input an
Expand Down
41 changes: 27 additions & 14 deletions source
Expand Up @@ -95556,20 +95556,6 @@ document.body.appendChild(text);

</ol>

<p><dfn id="escapingString">Escaping a string</dfn> (for the
purposes of the algorithm above) consists of replacing any
occurrences of the "<code title="">&amp;</code>" character by the
string "<code title="">&amp;amp;</code>", any occurrences of the
U+00A0 NO-BREAK SPACE character by the string "<code
title="">&amp;nbsp;</code>", and, if the algorithm was invoked in
the <i>attribute mode</i>, any occurrences of the "<code
title="">&quot;</code>" character by the string "<code
title="">&amp;quot;</code>", or if it was not, any occurrences of
the "<code title="">&lt;</code>" character by the string "<code
title="">&amp;lt;</code>", any occurrences of the "<code
title="">&gt;</code>" character by the string "<code
title="">&amp;gt;</code>".</p>

<p class="note">Entity reference nodes are <a
href="#entity-references">assumed to be expanded</a> by the user
agent, and are therefore not covered in the algorithm above.</p>
Expand All @@ -95591,6 +95577,33 @@ document.body.appendChild(text);
<span title="syntax-start-tag">start tag</span> would imply the end
tag for the <code>p</code>).</p>

<p><dfn id="escapingString">Escaping a string</dfn> (for the
purposes of the algorithm above) consists of running the following
steps:</p>

<ol>

<li><p>Replace any occurrence of the "<code title="">&amp;</code>"
character by the string "<code title="">&amp;amp;</code>".</p></li>

<li><p>Replace any occurrences of the U+00A0 NO-BREAK SPACE
character by the string "<code
title="">&amp;nbsp;</code>".</p></li>

<li><p>If the algorithm was invoked in the <i>attribute mode</i>,
replace any occurrences of the "<code title="">&quot;</code>"
character by the string "<code
title="">&amp;quot;</code>".</p></li>

<li><p>If the algorithm was <em>not</em> invoked in the
<i>attribute mode</i>, replace any occurrences of the "<code
title="">&lt;</code>" character by the string "<code
title="">&amp;lt;</code>", and any occurrences of the "<code
title="">&gt;</code>" character by the string "<code
title="">&amp;gt;</code>".</p></li>

</ol>


<h3>Parsing HTML fragments</h3>

Expand Down

0 comments on commit 2333a9b

Please sign in to comment.