RESOLVED FIXED 33191
CDATA sections are merged into Text nodes when normalize() is used
https://bugs.webkit.org/show_bug.cgi?id=33191
Summary CDATA sections are merged into Text nodes when normalize() is used
William J. Edney
Reported Tuesday, January 5, 2010 2:13:20 AM UTC
Created attachment 45855 [details] Testcase showing invalid merging behavior As the attached testcase demonstrates, Webkit violates the DOM Specification by merging adjacent CDATA sections into Text nodes when normalize() is used. The 'normalize()' method in the DOM Level 2 specification says: "Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes". Further, section 1.3 describing CDATA sections state that adjacent CDATA sections are not to be merged with each other when normalize() is used: "Adjacent CDATASection nodes are not merged by use of the normalize method of the Node interface" The attached testcase shows that the XML chunk starts out with 3 nodes under the document element in this order: - Text node - CDATA Section node - Text node and confirms that the document element has 3 child nodes before normalization and 1 child node after normalization (when it should still have 3, having preserved the above structure). This test passes on Mozilla and IE. This is failing on the latest Webkit build I have: build 52571. Cheers, - Bill
Attachments
Testcase showing invalid merging behavior (1022 bytes, text/html)
2010-01-04 18:13 PST, William J. Edney
no flags
patch (5.19 KB, patch)
2010-01-05 17:30 PST, Darin Adler
mitz: review+
Darin Adler
Comment 1 Tuesday, January 5, 2010 7:03:37 PM UTC
Looking at Node::normalize it seems the problem is using nodeType which returns TEXT_NODE for both text nodes and character data nodes. Instead we should call isTextNode and isElementNode in that function.
Darin Adler
Comment 2 Tuesday, January 5, 2010 10:51:55 PM UTC
Turns out I had it backwards. CDATASection nodes are text nodes. So we need to call nodeType more, not less.
Darin Adler
Comment 3 Tuesday, January 5, 2010 10:56:00 PM UTC
I’ll fix this.
Darin Adler
Comment 4 Wednesday, January 6, 2010 1:30:16 AM UTC
Darin Adler
Comment 5 Wednesday, January 6, 2010 1:36:12 AM UTC
William J. Edney
Comment 6 Wednesday, January 6, 2010 5:53:36 AM UTC
That was fast! Thanks Darin! Cheers, - Bill
Lucas Forschler
Comment 7 Wednesday, February 6, 2019 5:04:13 PM UTC
Mass moving XML DOM bugs to the "DOM" Component.
Note You need to log in before you can comment on or make changes to this bug.