Skip to content

cssParser fails with escaped quotes within string #11

@a1s

Description

@a1s

cssParser does not recognize escaped characters within string because the backslash character is consumed by the first group [\t !#$%&(-~]. For example, the following string in a css file makes xhtml2pdf fail with traceback: "\"}\"".

It helps if I put i_escape and i_escape_nl before the plain characters group in i_string_content rule:

--- cssParser.py.orig   2009-03-18 14:02:36.000000000 +0200
+++ cssParser.py    2011-02-18 11:19:35.386109400 +0200
@@ -281,7 +281,7 @@
     re_rgbcolor = re.compile(i_rgbcolor, _reflags)
     i_nl = u'\n|\r\n|\r|\f'
     i_escape_nl = u'\\\\(?:%s)' % i_nl
-        i_string_content = _orRule(u'[\t !#$%&(-~]', i_escape_nl, i_nonascii, i_escape)
+        i_string_content = _orRule(i_escape, i_escape_nl, u'[\t !#$%&(-~]', i_nonascii)
     i_string1 = u'\"((?:%s|\')*)\"' % i_string_content
     i_string2 = u'\'((?:%s|\")*)\'' % i_string_content
     i_string = _orRule(i_string1, i_string2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions