mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 09:45:06 +02: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:
committed by
Shannon Booth
parent
cdc264a62e
commit
cbd01b8efc
Notes:
github-actions[bot]
2026-03-26 07:31:55 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/cbd01b8efcf Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8619
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user