Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS - descendant attribute is parsed incorrectly ("div [bar]") #1174

Closed
jdelStrother opened this issue Oct 6, 2014 · 5 comments
Closed

CSS - descendant attribute is parsed incorrectly ("div [bar]") #1174

jdelStrother opened this issue Oct 6, 2014 · 5 comments

Comments

@jdelStrother
Copy link

Hi - I discovered that the CSS parser isn't correctly parsing nameless/classless/idless attribute selectors. I'd expect div [bar] to produce the same xpath as div *[bar], but instead it produces the same xpath as div[bar].

For example:

>> Nokogiri::VERSION
# => "1.6.3.1"
>> Nokogiri::CSS.xpath_for "div [bar]"
# => ["//div[@bar]"]
>> Nokogiri::CSS.xpath_for "div *[bar]"
# => ["//div//*[@bar]"]

I started looking into css/parser.y to try and figure it out, but nothing jumped out at me as obviously incorrect. Any hints?

@knu
Copy link
Member

knu commented Oct 6, 2014

You are right. I hacked up a fix for this, but it's kind of ugly. I'll post a PR later for review.

@knu
Copy link
Member

knu commented Oct 7, 2014

This is a minimum and a bit ugly fix that should work.

@tenderlove Can you come up with a better fix? I couldn't manage to get out of the parser conflict hell last night.

@knu knu closed this as completed in a155518 Oct 7, 2014
@knu
Copy link
Member

knu commented Oct 7, 2014

I worked out a better one and committed. Hope you can confirm this!

@tenderlove
Copy link
Member

@knu nice! Thank you!

@jdelStrother
Copy link
Author

Yep, works great for me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants