Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG: Crash when referencing (use) non-existing elements #1399

Closed
pbregener opened this issue Jul 20, 2021 · 0 comments · Fixed by #1401
Closed

SVG: Crash when referencing (use) non-existing elements #1399

pbregener opened this issue Jul 20, 2021 · 0 comments · Fixed by #1401
Milestone

Comments

@pbregener
Copy link
Contributor

Rendering a SVG that uses non-existing elements results in a crash.

This has been a problem in all v53 betas, including current master . The cairo-based version simply ignored those use statements.

There are various potentially trivial fixes, let me know if you'd prefer a PR over fixing this yourself @liZe :)

Example SVG:

<svg viewBox="0 0 16 10" xmlns="http://www.w3.org/2000/svg">
  <circle id="valid" cx="5" cy="5" r="4" stroke="green"/>
  <use href="#valid" x="6" fill="green"/>
  <use href="#notvalid" x="7" fill="red"/>
</svg>

Short backtrace:

  File "[...]\weasyprint\svg\defs.py", line 30, in use
    tree = svg.tree.get_child(parsed_url.fragment).copy()
AttributeError: 'NoneType' object has no attribute 'copy'

tree = svg.tree.get_child(parsed_url.fragment).copy()

pbregener added a commit to pbregener/WeasyPrint that referenced this issue Jul 20, 2021
@liZe liZe added this to the 53.0 milestone Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants