Files
ladybird/Tests/LibWeb/Ref/expected/svg-as-img-with-script-ref.html
Andreas Kling 91cf575b82 LibWeb: Disable script execution for SVG images loaded via <img>
SVG images loaded as <img> elements must not execute scripts per spec.
Previously, SVGScriptElement::process_the_script_element() did not
check whether scripting was disabled, so script processing was
triggered via the children_changed() callback during XML parsing,
causing a nested event loop spin.

Fix this by:
- Disabling scripting on the SVG image's Page
- Passing XMLScriptingSupport::Disabled to the XML document builder
- Checking is_scripting_disabled() in SVGScriptElement before
  processing any script element
- Logging a diagnostic when SVG XML parsing fails (previously the
  parse result was silently discarded)
2026-02-01 22:48:51 +01:00

14 lines
598 B
HTML

<!DOCTYPE html>
<style>svg { display: block; }</style>
<p>SVG scripts must not execute when loaded as an image.</p>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
<rect width="100" height="100" fill="green"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
<rect width="100" height="100" fill="green"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
<rect width="50" height="100" fill="green"/>
<rect x="50" width="50" height="100" fill="green"/>
</svg>