Skip to content

Commit

Permalink
LibWeb/XML: Set attributes using Element::set_attribute_ns
Browse files Browse the repository at this point in the history
Otherwise we'd end up ignoring attr prefixes and treating them as part
of the attribute's local name.
Fixes #3137.

This is a partial revert of b3fdeef,
but it fixes the underlying issue that it was working around.
  • Loading branch information
alimpfard committed Jan 4, 2025
1 parent c60ad5b commit 37ddaff
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Libraries/LibWeb/XML/XMLDocumentBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,13 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMap<XML::Name,
} else {
m_has_error = true;
}
} else if (attribute.key.contains(":"sv)) {
if (!attribute.key.starts_with("xml:"sv)) {
m_has_error = true;
}
}
MUST(node->set_attribute(MUST(FlyString::from_deprecated_fly_string(attribute.key)), MUST(String::from_byte_string(attribute.value))));

auto result = node->set_attribute_ns(m_namespace, MUST(FlyString::from_deprecated_fly_string(attribute.key)), MUST(String::from_byte_string(attribute.value)));
if (result.is_error()) {
m_has_error = true;
return;
}
}

m_current_node = node.ptr();
Expand Down

0 comments on commit 37ddaff

Please sign in to comment.