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

crash on unsupported css values #513

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

crash on unsupported css values #513

JGiard opened this issue Sep 29, 2017 · 1 comment
Assignees
Labels
bug Existing features not working as expected crash Problems preventing documents from being rendered
Milestone

Comments

@JGiard
Copy link

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 Existing features not working as expected crash Problems preventing documents from being rendered labels Sep 30, 2017
@liZe liZe added this to the v0.41 milestone Sep 30, 2017
@liZe
Copy link
Member

liZe commented Oct 1, 2017

Thank you!

@liZe liZe closed this as completed in f10bf7f Oct 1, 2017
netbsd-srcmastr referenced this issue in NetBSD/pkgsrc Oct 9, 2017
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 referenced this issue in NetBSD/pkgsrc Oct 22, 2017
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
Labels
bug Existing features not working as expected crash Problems preventing documents from being rendered
Projects
None yet
Development

No branches or pull requests

2 participants