Skip to content

Commit e21bd3b

Browse files
authored
Escape "<" and ">" when serializing attribute values
Avoid a class of XSS attacks where markup goes through a lossy parse-serialize-parse roundtrip and the original attribute value is parsed in the data state. This reverts 4eeb8a1. Fixes whatwg#6235.
1 parent 579fdba commit e21bd3b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

source

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136053,14 +136053,15 @@ console.assert(container.firstChild instanceof SuperP);
136053136053
<li><p>Replace any occurrences of the U+00A0 NO-BREAK SPACE character by the string "<code
136054136054
data-x="">&amp;nbsp;</code>".</p></li>
136055136055

136056-
<li><p>If the algorithm was invoked in the <i>attribute mode</i>, replace any occurrences of the
136057-
"<code data-x="">&quot;</code>" character by the string "<code
136058-
data-x="">&amp;quot;</code>".</p></li>
136056+
<li><p>Replace any occurrences of the "<code data-x="">&lt;</code>" character by the string
136057+
"<code data-x="">&amp;lt;</code>".</p></li>
136058+
136059+
<li><p>Replace any occurrences of the "<code data-x="">&gt;</code>" character by the string
136060+
"<code data-x="">&amp;gt;</code>".</p></li>
136059136061

136060-
<li><p>If the algorithm was <em>not</em> invoked in the <i>attribute mode</i>, replace any
136061-
occurrences of the "<code data-x="">&lt;</code>" character by the string "<code
136062-
data-x="">&amp;lt;</code>", and any occurrences of the "<code data-x="">&gt;</code>" character by
136063-
the string "<code data-x="">&amp;gt;</code>".</p></li>
136062+
<li><p>If the algorithm was invoked in the <i>attribute mode</i>, then replace any occurrences of
136063+
the "<code data-x="">&quot;</code>" character by the string "<code
136064+
data-x="">&amp;quot;</code>".</p></li>
136064136065
</ol>
136065136066

136066136067

0 commit comments

Comments
 (0)