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

crash on unsupported css values #513

Closed
JGiard opened this Issue Sep 29, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@JGiard

JGiard commented Sep 29, 2017

Hi,
I just upgraded from weasyprint 0.24 to weasyprint 0.40 and it seems to crash during css parsing

here is a sample of code to reproduce the issue :

from weasyprint import CSS
CSS(string=".foo { image-resolution: from-image; }")

and the stacktrace :

Traceback (most recent call last):
File "", line 1, in
File "/home/jg/.virtualenvs/fluid-topics/lib/python3.5/site-packages/weasyprint/init.py", line 267, in init
self.page_rules, self.fonts, font_config)
File "/home/jg/.virtualenvs/fluid-topics/lib/python3.5/site-packages/weasyprint/css/init.py", line 609, in preprocess_stylesheet
base_url, tinycss2.parse_declaration_list(rule.content)))
File "/home/jg/.virtualenvs/fluid-topics/lib/python3.5/site-packages/weasyprint/css/validation.py", line 2189, in preprocess_declarations
result = list(expander_(base_url, name, tokens))
File "/home/jg/.virtualenvs/fluid-topics/lib/python3.5/site-packages/weasyprint/css/validation.py", line 2136, in validate_non_shorthand
value = function(tokens)
File "/home/jg/.virtualenvs/fluid-topics/lib/python3.5/site-packages/weasyprint/css/validation.py", line 159, in single_token_validator
return function(tokens[0], *args)
File "/home/jg/.virtualenvs/fluid-topics/lib/python3.5/site-packages/weasyprint/css/validation.py", line 1106, in image_resolution
return get_resolution(token)
File "/home/jg/.virtualenvs/fluid-topics/lib/python3.5/site-packages/weasyprint/css/validation.py", line 218, in get_resolution
factor = RESOLUTION_TO_DPPX.get(token.unit)
AttributeError: 'IdentToken' object has no attribute 'unit'

It worked fine previously on 0.24 and produced a warning :

Ignored image-resolution: from-image at 1:8, invalid value.

I suppose it may be a missing feature from tinycss2 migration.

I removed the css value in my content since it is not supported but it might still be worth it to produce a warning instead of a crash

@liZe liZe self-assigned this Sep 30, 2017

@liZe liZe added bug crash labels Sep 30, 2017

@liZe liZe added this to the v0.41 milestone Sep 30, 2017

@liZe

This comment has been minimized.

Show comment
Hide comment
@liZe

liZe Oct 1, 2017

Member

Thank you!

Member

liZe commented Oct 1, 2017

Thank you!

@liZe liZe closed this in f10bf7f Oct 1, 2017

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Oct 9, 2017

kleink
py-weasyprint: update to 0.41.
Version 0.41
------------

Released on 2017-10-05.

WeasyPrint now depends on pdfrw >= 0.4.

New features:

* `#471 <https://github.com/Kozea/WeasyPrint/issues/471>`_:
  Support page marks and bleed.

Bug fixes:

* `#513 <https://github.com/Kozea/WeasyPrint/issues/513>`_:
  Don't crash on unsupported image-resolution values.
* `#506 <https://github.com/Kozea/WeasyPrint/issues/506>`_:
  Fix @font-face use with write_* methods.
* `#500 <https://github.com/Kozea/WeasyPrint/pull/500>`_:
  Improve readability of _select_source function.
* `#498 <https://github.com/Kozea/WeasyPrint/issues/498>`_:
  Use CSS prefixes as recommanded by the CSSWG.
* `#441 <https://github.com/Kozea/WeasyPrint/issues/441>`_:
  Fix rendering problems and crashes when using @font-face.
* `bb3a4db <https://github.com/Kozea/WeasyPrint/commit/bb3a4db>`_:
  Try to break pages after a block before trying to break inside it.
* `1d1654c <https://github.com/Kozea/WeasyPrint/commit/1d1654c>`_:
  Fix and test corner cases about named pages.

Documentation:

* `#508 <https://github.com/Kozea/WeasyPrint/pull/508>`_:
  Add missing libpangocairo dependency for Debian and Ubuntu.
* `a7b17fb <https://github.com/Kozea/WeasyPrint/commit/a7b17fb>`_:
  Add documentation on logged rendering steps.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Oct 22, 2017

kleink
py-weasyprint: update to 0.41.
Version 0.41
------------

Released on 2017-10-05.

WeasyPrint now depends on pdfrw >= 0.4.

New features:

* `#471 <https://github.com/Kozea/WeasyPrint/issues/471>`_:
  Support page marks and bleed.

Bug fixes:

* `#513 <https://github.com/Kozea/WeasyPrint/issues/513>`_:
  Don't crash on unsupported image-resolution values.
* `#506 <https://github.com/Kozea/WeasyPrint/issues/506>`_:
  Fix @font-face use with write_* methods.
* `#500 <https://github.com/Kozea/WeasyPrint/pull/500>`_:
  Improve readability of _select_source function.
* `#498 <https://github.com/Kozea/WeasyPrint/issues/498>`_:
  Use CSS prefixes as recommanded by the CSSWG.
* `#441 <https://github.com/Kozea/WeasyPrint/issues/441>`_:
  Fix rendering problems and crashes when using @font-face.
* `bb3a4db <https://github.com/Kozea/WeasyPrint/commit/bb3a4db>`_:
  Try to break pages after a block before trying to break inside it.
* `1d1654c <https://github.com/Kozea/WeasyPrint/commit/1d1654c>`_:
  Fix and test corner cases about named pages.

Documentation:

* `#508 <https://github.com/Kozea/WeasyPrint/pull/508>`_:
  Add missing libpangocairo dependency for Debian and Ubuntu.
* `a7b17fb <https://github.com/Kozea/WeasyPrint/commit/a7b17fb>`_:
  Add documentation on logged rendering steps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment