tokenizer mishandling .android class in selector

Issue #48 new
Anonymous created an issue

I have a bit of CSS that looks like this

.interstitial.android .webclip { ... stuff... }

When I process it the CSS with cssparse I get these errors

ERROR Selector: Unexpected IDENT. [253:20: roid] ERROR SelectorList: Invalid Selector: .interstitial.android .webclip

When I dug in I expected the tokenizer to tread android as one token, but instead it split it into two tokens 'and' and 'roid'.

The selectorText that was passed into self._tokenize2 near line 217 in css/selector.py was

selectorText [('CHAR', u'.', 253, 3), ('IDENT', u'interstitial', 253, 4), ('CHAR', u'.', 253, 16), ('IDENT', u'and', 253, 17), ('IDENT', u'roid', 253, 20), ('S', u' ', 253, 24), ('CHAR', u'.', 253, 25), ('IDENT', u'webclip', 253, 26), ('S', u' ', 253, 33)]

and shows that android has been split into to tokens.

Here is some context near my line 216 of css/seelector.py

try: # uses parent stylesheets namespaces if available, # otherwise given ones namespaces = self.parent.parentRule.parentStyleSheet.namespaces except AttributeError: pass print >> sys.stderr, "selectorText", selectorText tokenizer = self._tokenize2(selectorText) if not tokenizer: self._log.error(u'Selector: No selectorText given.') else: # prepare tokenlist:

I can avoid this problem by prefixing android, namely

.interstitial.browser-android .webclip { ... stuff ... }

Comments (2)

  1. JR Smith

    I'm seeing the same issue. There's a specific production for "and" here. It's related to media queries, since keyword "and" is used to combine expressions. I haven't spent enough time in the source to determine what needs to be done to fix, but I'm going to try my hand at it.

  2. C. Dot repo owner

    thanks for stepping in. I simply have not used Python and therefor this library myself for years now and am too busy with other things to properly take care of it :(

    thanks again!

  3. Log in to comment