Skip to content

Both angle braces must be escaped #164

@antelle

Description

@antelle

https://www.w3.org/TR/2014/CR-DOM-Parsing-20140617/#serializing

  1. If the require well-formed flag is set (its value is true), and node's data contains characters that are not matched by the XML Char production [XML10], then throw an exception; the serialization of this node's data would not be well-formed.
  2. Let markup be the value of node's data.
  3. Replace any occurrences of "&" in markup by "&".
  4. Replace any occurrences of "<" in markup by "&lt;".
  5. Replace any occurrences of ">" in markup by "&gt;".
  6. Return the value of markup.

Please add > to the list of escaped characters here (and above as well).
But this will break this test. Why are you expecting > to be left as is? This is not standard behavior.
Try this in browser:

var doc = new DOMParser().parseFromString('<test/>', 'text/xml');
doc.documentElement.appendChild(doc.createTextNode('hello ]]> there'));
new XMLSerializer().serializeToString(doc) // "<test>hello ]]&gt; there</test>"

Such behavior was added in 47fa9b8

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