linkedom
linkedom copied to clipboard
Characters (<) and (>) escaped incorrectly in xml attributes
For XML
document :
The left angle bracket (<) MUST NOT appear in their literal form,
[...] they MUST be escaped using [...] the string <".
The right angle bracket (>) [...] MUST be escaped using ">"
Full source : https://www.w3.org/TR/xml11/#syntax
Test snippet:
const document = (new DOMParser).parseFromString('<root attr="<>"></root>', 'text/xml');
assert(document.toString(), '<?xml version="1.0" encoding="utf-8"?><root attr="<>" />');
Expected: <?xml version="1.0" encoding="utf-8"?><root attr="<>" />
Got instead: <?xml version="1.0" encoding="utf-8"?><root attr="<>" />
Note :
- The
HTML
parser must not changed and does not have the same behavior - Only the
.toString
function must escaped, thegetAttribute("attr")
must continue to provide unescaped characters (<) and (>)