Skip to content

Characters (<) and (>) escaped incorrectly in xml attributes #216

@jblemee

Description

@jblemee

For XML document :

The left angle bracket (<) MUST NOT appear in their literal form,
 [...] they MUST be escaped using [...] the string &lt;". 
The right angle bracket (>) [...] MUST be escaped using "&gt;"

Full source : https://www.w3.org/TR/xml11/#syntax

Test snippet:

const document = (new DOMParser).parseFromString('<root attr="&lt;&gt;"></root>', 'text/xml');

assert(document.toString(), '<?xml version="1.0" encoding="utf-8"?><root attr="&lt;&gt;" />');

Expected: <?xml version="1.0" encoding="utf-8"?><root attr="&lt;&gt;" />
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, the getAttribute("attr") must continue to provide unescaped characters (<) and (>)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions