LibWeb: Avoid invoking Trusted Types where avoidable

Prevents observably calling Trusted Types, which can run arbitrary JS,
cause crashes due to use of MUST and allow arbitrary JS to modify
internal elements.
This commit is contained in:
Luke Wilde 2025-10-31 12:30:47 +00:00 committed by Tim Flynn
parent fb9406ddcd
commit 82bd3d3891
Notes: github-actions[bot] 2025-11-06 16:46:00 +00:00
83 changed files with 407 additions and 366 deletions

View file

@ -99,9 +99,9 @@ Utf16String HTMLOptionElement::value() const
}
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-option-value
WebIDL::ExceptionOr<void> HTMLOptionElement::set_value(Utf16String const& value)
void HTMLOptionElement::set_value(Utf16String const& value)
{
return set_attribute(HTML::AttributeNames::value, value);
set_attribute_value(HTML::AttributeNames::value, value.to_utf8_but_should_be_ported_to_utf16());
}
static void concatenate_descendants_text_content(DOM::Node const* node, StringBuilder& builder)
@ -129,7 +129,7 @@ String HTMLOptionElement::label() const
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-option-label
void HTMLOptionElement::set_label(String const& label)
{
MUST(set_attribute(HTML::AttributeNames::label, label));
set_attribute_value(HTML::AttributeNames::label, label);
// Note: this causes attribute_changed() to be called, which will update the <select>'s label
}