Regression(r206240): XMLSerializer.serializeToString() does not properly escape ...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Apr 2017 22:23:10 +0000 (22:23 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Apr 2017 22:23:10 +0000 (22:23 +0000)
commite01678d0db593b2dd9ef48d82bbf8f82e0986ead
tree595373f8b0243a22d06a370642635d61d8db8bcd
parent5d4b4d27f22e59c3a26ce688bf11243a9454fd7a
Regression(r206240): XMLSerializer.serializeToString() does not properly escape '<' / '>' in attribute values
https://bugs.webkit.org/show_bug.cgi?id=171132
<rdar://problem/31426752>

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Re-sync web-platform-tests/domparsing from upstream.

* web-platform-tests/domparsing/DOMParser-parseFromString-html.html:
* web-platform-tests/domparsing/DOMParser-parseFromString-xml-doctype.html:
* web-platform-tests/domparsing/DOMParser-parseFromString-xml.html:
* web-platform-tests/domparsing/XMLSerializer-serializeToString.html:
* web-platform-tests/domparsing/createContextualFragment.html:
* web-platform-tests/domparsing/innerhtml-01.xhtml:
* web-platform-tests/domparsing/innerhtml-03.xhtml:
* web-platform-tests/domparsing/innerhtml-04.html:
* web-platform-tests/domparsing/innerhtml-05.xhtml:
* web-platform-tests/domparsing/innerhtml-06.html:
* web-platform-tests/domparsing/innerhtml-07.html:
* web-platform-tests/domparsing/insert-adjacent.html:
* web-platform-tests/domparsing/insert_adjacent_html-xhtml.xhtml:
* web-platform-tests/domparsing/insert_adjacent_html.html:
* web-platform-tests/domparsing/outerhtml-01.html:
* web-platform-tests/domparsing/outerhtml-02.html:
* web-platform-tests/domparsing/style_attribute_html.html:
* web-platform-tests/domparsing/w3c-import.log:
* web-platform-tests/domparsing/xml-serialization.xhtml:

Source/WebCore:

Use XMLSerialization [1] in MarkupAccumulator::appendAttribute() when inXMLFragmentSerialization()
returns true, even if the node's associated document is an HTML document. When XMLSerializer.serializeToString()
is called on a Node, we want XML serialization, even if the node comes from an HTML document.

[1] https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization

Test: fast/dom/XMLSerializer-serializeToString-entities.html

* editing/MarkupAccumulator.cpp:
(WebCore::MarkupAccumulator::appendAttributeValue):
(WebCore::MarkupAccumulator::appendAttribute):
* editing/MarkupAccumulator.h:

LayoutTests:

Add layout test coverage. This test is passing in both Firefox and Chrome.

* fast/dom/XMLSerializer-serializeToString-entities-expected.txt: Added.
* fast/dom/XMLSerializer-serializeToString-entities.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215648 268f45cc-cd09-0410-ab3c-d52691b4dbfc
26 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/XMLSerializer-serializeToString-entities-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/XMLSerializer-serializeToString-entities.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-html.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml-doctype.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/XMLSerializer-serializeToString.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/createContextualFragment.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/innerhtml-01.xhtml
LayoutTests/imported/w3c/web-platform-tests/domparsing/innerhtml-03.xhtml
LayoutTests/imported/w3c/web-platform-tests/domparsing/innerhtml-04.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/innerhtml-05.xhtml
LayoutTests/imported/w3c/web-platform-tests/domparsing/innerhtml-06.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/innerhtml-07.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/insert-adjacent.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/insert_adjacent_html-xhtml.xhtml
LayoutTests/imported/w3c/web-platform-tests/domparsing/insert_adjacent_html.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/outerhtml-01.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/outerhtml-02.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/style_attribute_html.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/w3c-import.log
LayoutTests/imported/w3c/web-platform-tests/domparsing/xml-serialization.xhtml
Source/WebCore/ChangeLog
Source/WebCore/editing/MarkupAccumulator.cpp
Source/WebCore/editing/MarkupAccumulator.h