mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
LibWeb: Handle null namespace in prefix map serializing XML
A "namespace prefix map", see: https://w3c.github.io/DOM-Parsing/#the-namespace-prefix-map Is meant to also hold null namespaces: > where namespaceURI values are the map's unique keys > (which can include the null value representing no namespace) Which we previously neglected. This resulted in a crash for the updated WPT test.
This commit is contained in:
committed by
Tim Ledbetter
parent
8bd43f2cb9
commit
d5e41f1f72
Notes:
github-actions[bot]
2025-07-07 19:27:17 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/d5e41f1f720 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5320 Reviewed-by: https://github.com/tcl3 ✅
@@ -80,6 +80,25 @@ test(function() {
|
||||
assert_equals(serialize(root), '<root xmlns="uri1"><child xmlns=""/><child2 xmlns="uri2"/><child3/><child4 xmlns="uri4"/><child5 xmlns=""/></root>');
|
||||
}, 'Check if inconsistent xmlns="..." is dropped.');
|
||||
|
||||
test(function() {
|
||||
const root1 = parse('<package></package>');
|
||||
root1.setAttribute('xmlns', 'http://www.idpf.org/2007/opf');
|
||||
const manifest1 = root1.appendChild(root1.ownerDocument.createElement('manifest'));
|
||||
manifest1.setAttribute('xmlns', 'http://www.idpf.org/2007/opf');
|
||||
assert_equals(serialize(root1), '<package><manifest/></package>');
|
||||
|
||||
const root2 = parse('<package xmlns="http://www.idpf.org/2007/opf"></package>');
|
||||
const manifest2 = root2.appendChild(root2.ownerDocument.createElement('manifest'));
|
||||
manifest2.setAttribute('xmlns', 'http://www.idpf.org/2007/opf');
|
||||
assert_equals(serialize(root2),
|
||||
'<package xmlns="http://www.idpf.org/2007/opf"><manifest xmlns=""/></package>');
|
||||
|
||||
const root3 = parse('<package xmlns="http://www.idpf.org/2007/opf"></package>');
|
||||
const manifest3 = root3.appendChild(root3.ownerDocument.createElement('manifest'));
|
||||
assert_equals(serialize(root3),
|
||||
'<package xmlns="http://www.idpf.org/2007/opf"><manifest xmlns=""/></package>');
|
||||
}, 'Drop inconsistent xmlns="..." by matching on local name');
|
||||
|
||||
test(function() {
|
||||
let root = parse('<r xmlns:xx="uri"></r>');
|
||||
root.setAttributeNS('uri', 'name', 'v');
|
||||
@@ -230,8 +249,17 @@ test(function () {
|
||||
root.append(document.createElement("style"));
|
||||
root.append(document.createElement("style"));
|
||||
assert_equals(serialize(root), '<img xmlns=\"http://www.w3.org/1999/xhtml\"><style></style><style></style></img>');
|
||||
}, 'Check children were included for void elements')
|
||||
}, 'Check children were included for void elements');
|
||||
|
||||
test(function () {
|
||||
const root = parse('<root xmlns="" xmlns:foo="urn:bar"/>');
|
||||
root.setAttributeNS(XMLNS_URI, 'xmlns:foo', '');
|
||||
assert_equals(serialize(root), '<root xmlns="" xmlns:foo=""/>');
|
||||
}, 'Check if a prefix bound to an empty namespace URI ("no namespace") serialize');
|
||||
|
||||
test(function() {
|
||||
assert_equals(serialize(document.createAttribute("foobar")), "")
|
||||
}, 'Attribute nodes are serialized as the empty string')
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user