Kozea/tinycss2

Unclosed strings should produce parsing error

Closed this issue · 2 comments

I had expected unclosed strings to produce a syntax error, whether or not the string was automatically closed by the parser:

>>> tinycss2.parse_declaration_list('font-family: "blah')[0].value
[<WhitespaceToken>, <StringToken "blah">]
>>> tinycss2.parse_declaration_list('font-family: "blah; font-weight: 600')[0].value
[<WhitespaceToken>, <StringToken "blah; font-weight: 600">]

I think it would be valuable to have a syntax error in the latter case to help explain why the font-weight was missed.

liZe commented

Meeting end of file while consuming a string is not considered as an error in the current spec, but this has been changed in the draft.

As this change wouldn't help to add any new feature, I suppose that keeping this behavior is OK until the draft is released.

liZe commented

As this change wouldn't help to add any new feature, I suppose that keeping this behavior is OK until the draft is released.

The draft has been released, I've added a parse error. This change makes WeasyPrint reject rules with an EOF character, just as other browsers do.