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

feat: better exception message when a CSS selector is empty #2701

Merged
merged 1 commit into from
Nov 17, 2022

Conversation

flavorjones
Copy link
Member

What problem is this PR intended to solve?

Closes #2700

Previously this code

Nokogiri::HTML5.parse("<div></div>").css("")

would raise:

nokogiri/css/parser_extras.rb:86:in `on_error': unexpected '$' after '' (Nokogiri::CSS::SyntaxError)

Now:

nokogiri/lib/nokogiri/css.rb:46:in `xpath_for': empty CSS selector (Nokogiri::CSS::SyntaxError)

which I think we can all agree is clearer. The previous exception came from the bowels of racc and I timed out after digging into it for about 20 minutes.

Have you included adequate test coverage?

Yes!

Does this change affect the behavior of either the C or the Java implementations?

No.

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

Successfully merging this pull request may close these issues.

[bug] Nokogiri::CSS throws cryptic error messages when missing a parameter
1 participant