ms2ger avatar ms2ger committed 01751a5 Draft

Escape <, > and & in XML serialization.

Fixes <;.

Comments (0)

Files changed (3)

       <li>Let <var title="">markup</var> be the concatenation of
       "<code title="">&lt;![CDATA[</code>", <var title="">data</var>, and
       "<code title="">]]&gt;</code>".
-      <li>Return <var title="">markup</var>.
-    <p>Otherwise, return <var title="">data</var>.
+    <p>Otherwise, run the following steps:
+    <ol>
+      <li>Let <var title="">markup</var> be <var title="">data</var>.
+      <li>Replace any occurrences of "<code title="">&amp;</code>" in
+      <var title="">markup</var> by "<code title="">&amp;amp;</code>".
+      <li>Replace any occurrences of "<code title="">&lt;</code>" in
+      <var title="">markup</var> by "<code title="">&amp;lt;</code>".
+      <li>Replace any occurrences of "<code title="">&gt;</code>" in
+      <var title="">markup</var> by "<code title="">&amp;gt;</code>".
+    </ol>
+    <p>Return <var title="">markup</var>.
   <dt><a href=><code class=external data-anolis-spec=dom>DocumentFragment</code></a>
       <li>Let <var title>markup</var> be the concatenation of
       "<code title>&lt;![CDATA[</code>", <var title>data</var>, and
       "<code title>]]></code>".
-      <li>Return <var title>markup</var>.
-    <p>Otherwise, return <var title>data</var>.
+    <p>Otherwise, run the following steps:
+    <ol>
+      <li>Let <var title>markup</var> be <var title>data</var>.
+      <li>Replace any occurrences of "<code title>&amp;</code>" in
+      <var title>markup</var> by "<code title>&amp;amp;</code>".
+      <li>Replace any occurrences of "<code title>&lt;</code>" in
+      <var title>markup</var> by "<code title>&amp;lt;</code>".
+      <li>Replace any occurrences of "<code title>&gt;</code>" in
+      <var title>markup</var> by "<code title>&amp;gt;</code>".
+    </ol>
+    <p>Return <var title>markup</var>.
   <dt><code data-anolis-spec=dom>DocumentFragment</code>


+<?xml version="1.0" encoding="UTF-8" ?>
 <html xmlns="">
 <title>innerHTML in XHTML</title>
   el.appendChild(document.createElementNS("", "html:br"));
   assert_equals(el.innerHTML, "<html:br xmlns:html=\"\" />");
+test(function() {
+  var el = document.createElement("div");
+  el.appendChild(document.createTextNode("<>\"'&"));
+  assert_equals(el.innerHTML, "&lt;&gt;\"'&amp;");
+test(function() {
+  var el = document.createElement("div");
+  el.appendChild(document.createTextNode("&lt;&gt;&quot;&apos;&amp;"));
+  assert_equals(el.innerHTML, "&amp;lt;&amp;gt;&amp;quot;&amp;apos;&amp;amp;");
+test(function() {
+  var el = document.createElement("div");
+  el.appendChild(document.createTextNode("àו…\u00A0"));
+  assert_equals(el.innerHTML, "àו…\u00A0");
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.