mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 08:39:22 +00:00
LibWeb/SVG: Don't crash when a filter has no valid effects
This commit is contained in:
parent
0cff47828d
commit
438bb56160
Notes:
github-actions[bot]
2025-07-09 22:19:33 +00:00
Author: https://github.com/tcl3
Commit: 438bb56160
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5379
Reviewed-by: https://github.com/gmta ✅
5 changed files with 17 additions and 4 deletions
|
@ -653,7 +653,7 @@ void NodeWithStyle::apply_style(CSS::ComputedProperties const& computed_style)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (auto* filter_element = as_if<SVG::SVGFilterElement>(*maybe_filter)) {
|
if (auto* filter_element = as_if<SVG::SVGFilterElement>(*maybe_filter)) {
|
||||||
Optional<Gfx::Filter> new_filter = filter_element->gfx_filter();
|
auto new_filter = filter_element->gfx_filter();
|
||||||
|
|
||||||
if (!new_filter.has_value())
|
if (!new_filter.has_value())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -73,7 +73,7 @@ void SVGFilterElement::attribute_changed(FlyString const& name, Optional<String>
|
||||||
m_primitive_units = AttributeParser::parse_units(value.value_or({}));
|
m_primitive_units = AttributeParser::parse_units(value.value_or({}));
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::Filter SVGFilterElement::gfx_filter()
|
Optional<Gfx::Filter> SVGFilterElement::gfx_filter()
|
||||||
{
|
{
|
||||||
HashMap<String, Gfx::Filter> result_map;
|
HashMap<String, Gfx::Filter> result_map;
|
||||||
Optional<Gfx::Filter> root_filter;
|
Optional<Gfx::Filter> root_filter;
|
||||||
|
@ -146,7 +146,7 @@ Gfx::Filter SVGFilterElement::gfx_filter()
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
|
|
||||||
return *root_filter;
|
return root_filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/filter-effects/#element-attrdef-filter-filterunits
|
// https://drafts.fxtf.org/filter-effects/#element-attrdef-filter-filterunits
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
|
|
||||||
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
||||||
|
|
||||||
Gfx::Filter gfx_filter();
|
Optional<Gfx::Filter> gfx_filter();
|
||||||
|
|
||||||
GC::Ref<SVGAnimatedEnumeration> filter_units() const;
|
GC::Ref<SVGAnimatedEnumeration> filter_units() const;
|
||||||
GC::Ref<SVGAnimatedEnumeration> primitive_units() const;
|
GC::Ref<SVGAnimatedEnumeration> primitive_units() const;
|
||||||
|
|
1
Tests/LibWeb/Text/expected/SVG/empty-filter-crash.txt
Normal file
1
Tests/LibWeb/Text/expected/SVG/empty-filter-crash.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
PASS (didn't crash)
|
12
Tests/LibWeb/Text/input/SVG/empty-filter-crash.html
Normal file
12
Tests/LibWeb/Text/input/SVG/empty-filter-crash.html
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<svg>
|
||||||
|
<filter id="empty"></filter>
|
||||||
|
<g filter="url(#empty)"/>
|
||||||
|
</svg>
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
// FIXME: This should be a crash test.
|
||||||
|
test(() => {
|
||||||
|
println("PASS (didn't crash)");
|
||||||
|
})
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue