Skip to content

Commit

Permalink
[svn r3835] r4520@delle: sbehnel | 2008-06-20 09:48:39 +0200
Browse files Browse the repository at this point in the history
 CSS selector parser accidentally merged non-adjacent classes

--HG--
branch : trunk
  • Loading branch information
scoder committed Jun 20, 2008
1 parent 3af9e22 commit 87bf4d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lxml/cssselect.py
Expand Up @@ -738,6 +738,8 @@ def parse_simple_selector(stream):
result = Pseudo(result, type, ident)
continue
else:
if peek == ' ':
stream.next()
break
# FIXME: not sure what "negation" is
return result
Expand Down Expand Up @@ -823,7 +825,10 @@ def tokenize(s):
while 1:
match = _whitespace_re.match(s, pos=pos)
if match:
preceding_whitespace_pos = pos
pos = match.end()
else:
preceding_whitespace_pos = 0
if pos >= len(s):
return
match = _count_re.match(s, pos=pos)
Expand All @@ -839,6 +844,8 @@ def tokenize(s):
pos += 2
continue
if c in '>+~,.*=[]()|:#':
if c in '.#' and preceding_whitespace_pos > 0:
yield Token(' ', preceding_whitespace_pos)
yield Token(c, pos)
pos += 1
continue
Expand Down
8 changes: 8 additions & 0 deletions src/lxml/tests/test_css.py
Expand Up @@ -46,6 +46,14 @@ class CSSTestCase(HelperTestCase):
('div.dialog', 51),
('div .dialog', 51),
('div.character, div.dialog', 99),
('div.direction.dialog', 0),
('div.dialog.direction', 0),
('div.dialog.scene', 1),
('div.scene.scene', 1),
('div.scene .scene', 0),
('div.direction .dialog ', 0),
('div .dialog .direction', 4),
('div.dialog .dialog .direction', 4),
('#speech5', 1),
('div#speech5', 1),
('div #speech5', 1),
Expand Down

0 comments on commit 87bf4d3

Please sign in to comment.