Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jblemee opened this issue Aug 18, 2023 · 0 comments
Open

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

jblemee opened this issue Aug 18, 2023 · 0 comments

Comments

@jblemee
Copy link

jblemee commented Aug 18, 2023

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 (>)
@jblemee jblemee changed the title Characters (&), (<) and (>) escaped incorrectly in xml attributes Characters (<) and (>) escaped incorrectly in xml attributes Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant