New issue
Advanced search Search tips

Issue 868838 link

Starred by 2 users

Issue metadata

Status: ExternalDependency
Owner: ----
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

XMLSerializer returns wrong text

Reported by microshi...@gmail.com, Jul 30

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36

Steps to reproduce the problem:
var xmlText = `<?xml version="1.0" encoding="UTF-8"?>
<Ping>
<Value>Test</Value>
</Ping>`;

var xml = new DOMParser().parseFromString(xmlText, "application/xml");

var xmlSerializedText = new XMLSerializer().serializeToString(xml);
if (xmlSerializedText !== xmlText) {
  console.log(xmlSerializedText);
  throw Error("Wrong serialized text");
}
alert("Success");

What is the expected behavior?
Must show Success dialog if serialized text is equal to xmlText variable

What went wrong?
Serialized text is different from xmlText variable
<?xml version="1.0" encoding="UTF-8"?> <- Doesn't have \n symbol

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 67.0.3396.99  Channel: n/a
OS Version: OS X 10.13.4
Flash Version: 

You can run test script http://jsfiddle.net/rydcgx76/1/

Mozilla works fine
Safari has the same problem
 
This linebreak is not part of the prolog node:
https://www.w3.org/TR/REC-xml/#sec-prolog-dtd

This linebreak is between the prolog node and the root node, that is outside of the root.
In other words it's a whitespace node outside of the root which can't exist as per the specification AFAICT.

The spec doesn't seem to say anything about this particular case:
https://www.w3.org/TR/REC-xml/#sec-white-space
Components: Blink>XML
Status: ExternalDependency (was: Unconfirmed)
#c1 is right. We have no ways to preserve whitespace outside of the root element.

The specification about serialization is here: https://w3c.github.io/DOM-Parsing/#xml-serializing-a-document-node
If we follow it, we should not serialize <?xml version...?> too.

Reporter, would you file a specification bug on https://github.com/w3c/DOM-Parsing/issues please? We can't implement the behavior which does not match to the specification.



Sign in to add a comment