Selector parsing gets confused by commata in regexes #179

eyealike opened this Issue Apr 2, 2012 · 3 comments


None yet

2 participants

eyealike commented Apr 2, 2012

The selector div, li:matches([0-9,]+) causes a java.util.regex.PatternSyntaxException because QueryParser (line 63) thinks that the comma inside the regex is a combinator and thus extracts , li:matches([0-9 as the second alternative.

Instead of scanning ahead with `chompTo(","), the parser needs to parse its way through the alternative until it reaches a comma or the end of a string. That way, commata in regular expressions will be correctly interpreted as part of the regex.

Note that there may be many more variations of this bug in the parser. Wherever a construct allows embedding an arbitrary string one should expect this problem. [attr=a,b] for example is likely to cause the same issue. In a way, any invocation of chompTo() needs to examined.

eyealike commented Apr 2, 2012

I currently work around this by escaping the comma in the regex as in div, li:matches([0-9\\x2C]+).

@jhy jhy closed this in 249e5a8 Apr 3, 2012
jhy commented Apr 3, 2012

Thanks for pointing this out! Fixed now.

eyealike commented Apr 4, 2012

Thank you!

On Mon, Apr 2, 2012 at 7:42 PM, Jonathan Hedley <


Thanks for pointing this out! Fixed now.

Reply to this email directly or view it on GitHub:
#179 (comment)

Hannes Schmidt
Software Engineer
Eyealike, Inc.
206 696 2316

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment