Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3c61ff323d75b60ba91bbae6ed6b7ec7c1537848
https://github.com/WebKit/WebKit/commit/3c61ff323d75b60ba91bbae6ed6b7ec7c1537848
Author: Chris Dumez <[email protected]>
Date: 2026-04-14 (Tue, 14 Apr 2026)
Changed paths:
M
LayoutTests/fast/dom/XMLSerializer-attribute-namespace-prefix-conflicts-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/domparsing/XMLSerializer-serializeToString-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/domparsing/XMLSerializer-serializeToString.html
M Source/WebCore/editing/MarkupAccumulator.cpp
M Source/WebCore/editing/MarkupAccumulator.h
Log Message:
-----------
Fix XMLSerializer namespace handling in MarkupAccumulator
https://bugs.webkit.org/show_bug.cgi?id=312126
Reviewed by Darin Adler and Anne van Kesteren.
XMLSerializer had several namespace-related bugs:
1. appendNamespace() emitted a redundant xmlns="" on elements whose parent
already reset the default namespace to empty. The check only tested for
a non-null default namespace entry, but the empty string impl is non-null.
Fix: also check that the existing default namespace has non-zero length.
2. appendOpenTag() always emitted a default namespace declaration for
prefix-less elements with a namespace URI, even when a prefix already
mapped to that URI was in scope. Fix: look up the URI in the bidirectional
namespace map and emit prefix:localName when a match is found. Skip this
when the element carries its own xmlns attribute, matching Firefox and
Chrome behavior.
3. appendOpenTag() prepended "xml:" for elements in the XML namespace but
appendEndTag() used tagQName().toString(), producing mismatched tags
(e.g. <xml:foo>...</foo>). Similarly, elements whose prefix was resolved
from an ancestor namespace mapping had mismatched end tags.
Fix: store the full computed qualified name on a stack and use it for
both start and end tags, replacing the previous WeakHashMap with a
Vector-based stack since elements open and close in strict LIFO order.
*
LayoutTests/fast/dom/XMLSerializer-attribute-namespace-prefix-conflicts-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/domparsing/XMLSerializer-serializeToString-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/domparsing/XMLSerializer-serializeToString.html:
* Source/WebCore/editing/MarkupAccumulator.cpp:
(WebCore::MarkupAccumulator::appendEndTag):
(WebCore::MarkupAccumulator::appendNamespace):
(WebCore::MarkupAccumulator::appendOpenTag):
* Source/WebCore/editing/MarkupAccumulator.h:
Canonical link: https://commits.webkit.org/311184@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications