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

CSS tuple index out of range when parsing flex: ; #2012

Closed
ThiefMaster opened this issue Dec 1, 2023 · 3 comments
Closed

CSS tuple index out of range when parsing flex: ; #2012

ThiefMaster opened this issue Dec 1, 2023 · 3 comments
Labels
crash Problems preventing documents from being rendered
Milestone

Comments

@ThiefMaster
Copy link

  File "indico/modules/receipts/util.py", line 162, in create_pdf
    css = CSS(string=f'{css}{DEFAULT_CSS}', url_fetcher=css_url_fetcher)
  File "__init__.py", line 296, in __init__
    preprocess_stylesheet(
  File "weasyprint/css/__init__.py", line 887, in preprocess_stylesheet
    declarations = list(preprocess_declarations(
  File "weasyprint/css/validation/__init__.py", line 118, in preprocess_declarations
    result = list(expander_(base_url, name, tokens))
  File "weasyprint/css/validation/expanders.py", line 94, in generic_expander_wrapper
    for new_name, new_token in result:
  File "weasyprint/css/validation/expanders.py", line 603, in expand_flex
    line, column = tokens[0].source_line, tokens[0].source_column

Easy to reproduce with a stylesheet like this:

.foo {
  flex: ;
}
@liZe liZe added the crash Problems preventing documents from being rendered label Dec 1, 2023
@liZe
Copy link
Member

liZe commented Dec 1, 2023

Hi,

Really funny bug, thanks for the report! The problem happens with many shorthand properties.

@liZe
Copy link
Member

liZe commented Dec 1, 2023

The problem happens with many shorthand properties.

And some properties too. So strange that nobody ever complained about this!

And even stranger: browsers don’t show the same behaviour. Chrome and Firefox mark the rule as invalid, but Safari seems to accept the empty declaration.

Time to read the specification carefully!

@liZe liZe closed this as completed in 0f7a45e Dec 4, 2023
@liZe
Copy link
Member

liZe commented Dec 4, 2023

Time to read the specification carefully!

As far as I can tell, empty values are allowed by grammar, but no property or shorthand allows them.

@liZe liZe added this to the 61.0 milestone Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Problems preventing documents from being rendered
Projects
None yet
Development

No branches or pull requests

2 participants