WebReflection / WebReflection/linkedom

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

Open
#216 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
2.1k
Forks
104
PR merge metrics
No merged PRs in 30d

Description

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 (>)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the DOMParser and XML toString behavior shown in the supplied test snippet, reproducing it first. Done means XML serialization escapes angle brackets in attribute values, getAttribute("attr") still returns unescaped characters, and HTML parsing remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, xml
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.