mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Implement TrustedTypes spec for the concept of set_attribute_ns
This commit is contained in:
parent
4b00a61479
commit
e2adce84e7
Notes:
github-actions[bot]
2025-10-27 16:16:30 +00:00
Author: https://github.com/tete17
Commit: e2adce84e7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6057
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/Lubrsi ✅
4 changed files with 20 additions and 9 deletions
|
|
@ -164,16 +164,16 @@ void XMLDocumentBuilder::element_start(XML::Name const& name, OrderedHashMap<XML
|
|||
if (attribute.key == "xmlns" || attribute.key.starts_with("xmlns:"sv)) {
|
||||
// The prefix xmlns is used only to declare namespace bindings and is by definition bound to the namespace name http://www.w3.org/2000/xmlns/.
|
||||
if (!attribute.key.is_one_of("xmlns:"sv, "xmlns:xmlns"sv)) {
|
||||
if (!node->set_attribute_ns(Namespace::XMLNS, MUST(String::from_byte_string(attribute.key)), MUST(String::from_byte_string(attribute.value))).is_error())
|
||||
if (!node->set_attribute_ns(Namespace::XMLNS, MUST(String::from_byte_string(attribute.key)), Utf16String::from_utf8(attribute.value)).is_error())
|
||||
continue;
|
||||
}
|
||||
m_has_error = true;
|
||||
} else if (attribute.key.contains(':')) {
|
||||
if (auto ns = namespace_for_name(attribute.key); ns.has_value()) {
|
||||
if (!node->set_attribute_ns(ns.value(), MUST(String::from_byte_string(attribute.key)), MUST(String::from_byte_string(attribute.value))).is_error())
|
||||
if (!node->set_attribute_ns(ns.value(), MUST(String::from_byte_string(attribute.key)), Utf16String::from_utf8(attribute.value)).is_error())
|
||||
continue;
|
||||
} else if (attribute.key.starts_with("xml:"sv)) {
|
||||
if (auto maybe_error = node->set_attribute_ns(Namespace::XML, MUST(String::from_byte_string(attribute.key)), MUST(String::from_byte_string(attribute.value))); !maybe_error.is_error())
|
||||
if (auto maybe_error = node->set_attribute_ns(Namespace::XML, MUST(String::from_byte_string(attribute.key)), Utf16String::from_utf8(attribute.value)); !maybe_error.is_error())
|
||||
continue;
|
||||
}
|
||||
m_has_error = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue