Log Message
XMLSerializer.serializeToString() doesn't properly escape \n, \n and \t https://bugs.webkit.org/show_bug.cgi?id=227844
Reviewed by Darin Adler. LayoutTests/imported/w3c: Rebaseline WPT test now that one more subtest is passing. * web-platform-tests/domparsing/XMLSerializer-serializeToString-expected.txt: Source/WebCore: XMLSerializer.serializeToString() doesn't properly escape \n, \n and \t. This is causing the "check XMLSerializer.serializeToString escapes attribute values for roundtripping" subtest to fail in WebKit on: http://wpt.live/domparsing/XMLSerializer-serializeToString.html Chrome and Firefox both escape these and pass this WPT subtest. The specification does not indicate we should escape those: - https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value But there is an open bug about this: - https://github.com/w3c/DOM-Parsing/issues/59 No new tests, rebaselined existing test. * editing/MarkupAccumulator.cpp: (WebCore::elementCannotHaveEndTag): * editing/MarkupAccumulator.h:
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (279814 => 279815)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-07-11 04:16:05 UTC (rev 279814)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-07-11 18:20:53 UTC (rev 279815)
@@ -1,3 +1,14 @@
+2021-07-11 Chris Dumez <[email protected]>
+
+ XMLSerializer.serializeToString() doesn't properly escape \n, \n and \t
+ https://bugs.webkit.org/show_bug.cgi?id=227844
+
+ Reviewed by Darin Adler.
+
+ Rebaseline WPT test now that one more subtest is passing.
+
+ * web-platform-tests/domparsing/XMLSerializer-serializeToString-expected.txt:
+
2021-07-10 Chris Dumez <[email protected]>
document.readyState should be "complete" after calling DOMParser.parseFromString()
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/domparsing/XMLSerializer-serializeToString-expected.txt (279814 => 279815)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/domparsing/XMLSerializer-serializeToString-expected.txt 2021-07-11 04:16:05 UTC (rev 279814)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/domparsing/XMLSerializer-serializeToString-expected.txt 2021-07-11 18:20:53 UTC (rev 279815)
@@ -12,7 +12,7 @@
PASS Check if the prefix of an attribute is replaced with another existing prefix mapped to the same namespace URI.
FAIL Check if the prefix of an attribute is NOT preserved in a case where neither its prefix nor its namespace URI is not already used. assert_equals: expected "<r xmlns:xx=\"uri\" xmlns:ns1=\"uri2\" ns1:name=\"value\"/>" but got "<r xmlns:xx=\"uri\" p:name=\"value\" xmlns:p=\"uri2\"/>"
FAIL Check if the prefix of an attribute is replaced with a generated one in a case where the prefix is already mapped to a different namespace URI. assert_equals: expected "<r xmlns:xx=\"uri\" xmlns:ns1=\"uri2\" ns1:name=\"value\"/>" but got "<r xmlns:xx=\"uri\" NS1:name=\"value\" xmlns:NS1=\"uri2\"/>"
-FAIL check XMLSerializer.serializeToString escapes attribute values for roundtripping assert_in_array: value "<root attr=\"\t\"/>" not in array ["<root attr=\"	\"/>", "<root attr=\"	\"/>"]
+PASS check XMLSerializer.serializeToString escapes attribute values for roundtripping
FAIL Check if attribute serialization takes into account of following xmlns:* attributes assert_equals: expected "<root xmlns:ns1=\"uri1\" ns1:foobar=\"value1\" xmlns:p=\"uri2\"/>" but got "<root p:foobar=\"value1\" xmlns:p=\"uri1\" xmlns:p=\"uri2\"/>"
FAIL Check if attribute serialization takes into account of the same prefix declared in an ancestor element assert_equals: expected "<root xmlns:p=\"uri1\"><child xmlns:ns1=\"uri2\" ns1:foobar=\"v\"/></root>" but got "<root xmlns:p=\"uri1\"><child NS1:foobar=\"v\" xmlns:NS1=\"uri2\"/></root>"
FAIL Check if start tag serialization drops element prefix if the namespace is same as inherited default namespace. assert_equals: expected "<root xmlns=\"u1\"><child xmlns:p=\"u1\"/></root>" but got "<root xmlns=\"u1\"><p:child xmlns:p=\"u1\"/></root>"
Modified: trunk/Source/WebCore/ChangeLog (279814 => 279815)
--- trunk/Source/WebCore/ChangeLog 2021-07-11 04:16:05 UTC (rev 279814)
+++ trunk/Source/WebCore/ChangeLog 2021-07-11 18:20:53 UTC (rev 279815)
@@ -1,3 +1,28 @@
+2021-07-11 Chris Dumez <[email protected]>
+
+ XMLSerializer.serializeToString() doesn't properly escape \n, \n and \t
+ https://bugs.webkit.org/show_bug.cgi?id=227844
+
+ Reviewed by Darin Adler.
+
+ XMLSerializer.serializeToString() doesn't properly escape \n, \n and \t.
+
+ This is causing the "check XMLSerializer.serializeToString escapes attribute values for roundtripping" subtest to fail in WebKit on:
+ http://wpt.live/domparsing/XMLSerializer-serializeToString.html
+
+ Chrome and Firefox both escape these and pass this WPT subtest.
+
+ The specification does not indicate we should escape those:
+ - https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value
+ But there is an open bug about this:
+ - https://github.com/w3c/DOM-Parsing/issues/59
+
+ No new tests, rebaselined existing test.
+
+ * editing/MarkupAccumulator.cpp:
+ (WebCore::elementCannotHaveEndTag):
+ * editing/MarkupAccumulator.h:
+
2021-07-10 Chris Dumez <[email protected]>
document.readyState should be "complete" after calling DOMParser.parseFromString()
Modified: trunk/Source/WebCore/editing/MarkupAccumulator.cpp (279814 => 279815)
--- trunk/Source/WebCore/editing/MarkupAccumulator.cpp 2021-07-11 04:16:05 UTC (rev 279814)
+++ trunk/Source/WebCore/editing/MarkupAccumulator.cpp 2021-07-11 18:20:53 UTC (rev 279815)
@@ -60,6 +60,9 @@
{ ">", 4, EntityGt },
{ """, 6, EntityQuot },
{ " ", 6, EntityNbsp },
+ { "	", 4, EntityTab },
+ { " ", 5, EntityLineFeed },
+ { " ", 5, EntityCarriageReturn },
};
enum EntitySubstitutionIndex {
@@ -69,11 +72,19 @@
EntitySubstitutionGtIndex = 3,
EntitySubstitutionQuotIndex = 4,
EntitySubstitutionNbspIndex = 5,
+ EntitySubstitutionTabIndex = 6,
+ EntitySubstitutionLineFeedIndex = 7,
+ EntitySubstitutionCarriageReturnIndex = 8,
};
static const unsigned maximumEscapedentityCharacter = noBreakSpace;
static const uint8_t entityMap[maximumEscapedentityCharacter + 1] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ EntitySubstitutionTabIndex, // '\t'.
+ EntitySubstitutionLineFeedIndex, // '\n'.
+ 0, 0,
+ EntitySubstitutionCarriageReturnIndex, // '\r'.
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
EntitySubstitutionQuotIndex, // '"'.
0, 0, 0,
EntitySubstitutionAmpIndex, // '&'.
Modified: trunk/Source/WebCore/editing/MarkupAccumulator.h (279814 => 279815)
--- trunk/Source/WebCore/editing/MarkupAccumulator.h 2021-07-11 04:16:05 UTC (rev 279814)
+++ trunk/Source/WebCore/editing/MarkupAccumulator.h 2021-07-11 18:20:53 UTC (rev 279815)
@@ -46,6 +46,9 @@
EntityGt = 0x0004,
EntityQuot = 0x0008,
EntityNbsp = 0x0010,
+ EntityTab = 0x0020,
+ EntityLineFeed = 0x0040,
+ EntityCarriageReturn = 0x0080,
// Non-breaking space needs to be escaped in innerHTML for compatibility reason. See http://trac.webkit.org/changeset/32879
// However, we cannot do this in a XML document because it does not have the entity reference defined (See the bug 19215).
@@ -52,7 +55,7 @@
EntityMaskInCDATA = 0,
EntityMaskInPCDATA = EntityAmp | EntityLt | EntityGt,
EntityMaskInHTMLPCDATA = EntityMaskInPCDATA | EntityNbsp,
- EntityMaskInAttributeValue = EntityAmp | EntityLt | EntityGt | EntityQuot,
+ EntityMaskInAttributeValue = EntityAmp | EntityLt | EntityGt | EntityQuot | EntityTab | EntityLineFeed | EntityCarriageReturn,
EntityMaskInHTMLAttributeValue = EntityAmp | EntityQuot | EntityNbsp,
};
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
