w3c / w3c/DOM-Parsing

It's possible for 'generate a prefix' algorithm to generate a prefix conflicting with an existing one

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

Nobody has claimed this yet.

xml-serialization
Dominant language
HTML
Stars
28
Forks
14
Avg merge
3h 10m
Merged PRs (30d)
1

Description

https://w3c.github.io/DOM-Parsing/#generating-namespace-prefixes

The algorithm just generates 'ns1', 'ns2', ... without checking existence of generated prefixes.
So, the following example serializes two xmlns:ns1 on child element if we follow the current specification. WPT domparsing/XMLSerializer-serializeToString.html already has a test case ("Check if "ns1" is generated even if the element already has xmlns:ns1.").

const root = (new DOMParser()).parseFromString('<root xmlns:ns2="uri2"><child xmlns:ns1="uri1" xmlns:a0="uri1" xmlns:NS1="uri1"/></root>', 'text/xml').documentElement;
root.firstChild.setAttributeNS('uri3', 'attr1', 'value1');
console.log((new XMLSerializer()).serializeToString(root));

The algorithm should have a loop until a generated prefix is not found.

Contributor guide

Open the contributing guide

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 generating namespace prefixes algorithm in the linked DOM-Parsing specification and review WPT domparsing/XMLSerializer-serializeToString.html, including the existing ns1 test. Done means generated prefixes are checked with the specification’s “found” condition so serialization does not create a conflicting duplicate prefix.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.