mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 02:10:26 +00:00
LibWeb: Use fallible FormAssociatedElement cast in form elements filter
The `HTMLFormControlsCollection` filter iterates all descendants of the
form's root, which may include non HTMLElement elements such as SVG
elements. The unchecked `as<FormAssociatedElement>` cast would crash on
these elements. Use `as_if` with a null check instead.
This fixes a regression introduced in 9af3e34875.
This commit is contained in:
parent
cdc264a62e
commit
cbd01b8efc
Notes:
github-actions[bot]
2026-03-26 07:31:55 +00:00
Author: https://github.com/tcl3
Commit: cbd01b8efc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8619
2 changed files with 11 additions and 3 deletions
|
|
@ -519,11 +519,14 @@ static bool is_form_control(DOM::Element const& element, HTMLFormElement const&
|
|||
return false;
|
||||
}
|
||||
|
||||
auto const& form_associated_element = as<FormAssociatedElement>(element);
|
||||
if (form_associated_element.form() != &form)
|
||||
auto const* form_associated_element = as_if<FormAssociatedElement>(element);
|
||||
if (!form_associated_element)
|
||||
return false;
|
||||
|
||||
if (!form_associated_element.is_listed())
|
||||
if (form_associated_element->form() != &form)
|
||||
return false;
|
||||
|
||||
if (!form_associated_element->is_listed())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue