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

Nokogiri::CSS::SyntaxError: unexpected '|' after '#<Nokogiri::CSS::Node:0x000000012ae10458>' #120

Closed
shanecav84 opened this issue Feb 14, 2022 · 8 comments

Comments

@shanecav84
Copy link

shanecav84 commented Feb 14, 2022

This is an issue that exists with Nokogiri 1.13.1, but not 1.13.0. There was a change in how XPath selectors are handled in CSS rules1 but I don't know enough to be certain that's the cause.

Failure here:

doc.at_css("table|table[@table|name='#{@name}']")

Backtrace:

.../nokogiri-1.13.1/lib/nokogiri/css/parser_extras.rb:84:in `on_error'
(eval):3:in `_racc_do_parse_c'
(eval):3:in `do_parse'
.../nokogiri-1.13.1/lib/nokogiri/css/parser_extras.rb:66:in `parse'
.../nokogiri-1.13.1/lib/nokogiri/css/parser_extras.rb:76:in `xpath_for'
.../nokogiri-1.13.1/lib/nokogiri/css.rb:46:in `xpath_for'
.../nokogiri-1.13.1/lib/nokogiri/xml/searchable.rb:246:in `block in xpath_query_from_css_rule'
.../nokogiri-1.13.1/lib/nokogiri/xml/searchable.rb:245:in `map'
.../nokogiri-1.13.1/lib/nokogiri/xml/searchable.rb:245:in `xpath_query_from_css_rule'
.../nokogiri-1.13.1/lib/nokogiri/xml/searchable.rb:237:in `block in css_rules_to_xpath'
.../nokogiri-1.13.1/lib/nokogiri/xml/searchable.rb:237:in `map'
.../nokogiri-1.13.1/lib/nokogiri/xml/searchable.rb:237:in `css_rules_to_xpath'
.../nokogiri-1.13.1/lib/nokogiri/xml/searchable.rb:206:in `css_internal'
.../nokogiri-1.13.1/lib/nokogiri/xml/searchable.rb:129:in `css'
.../nokogiri-1.13.1/lib/nokogiri/xml/searchable.rb:141:in `at_css'
.../odf-report-0.7.2/lib/odf-report/table.rb:75:in `find_table_node'
.../odf-report-0.7.2/lib/odf-report/table.rb:13:in `replace!'
.../odf-report-0.7.2/lib/odf-report/report.rb:61:in `block (3 levels) in generate'
.../odf-report-0.7.2/lib/odf-report/report.rb:61:in `each'
.../odf-report-0.7.2/lib/odf-report/report.rb:61:in `block (2 levels) in generate'
.../odf-report-0.7.2/lib/odf-report/template.rb:83:in `process_entry'
.../odf-report-0.7.2/lib/odf-report/template.rb:35:in `block (2 levels) in update_files'
.../rubyzip-2.3.2/lib/zip/entry.rb:540:in `get_input_stream'
.../odf-report-0.7.2/lib/odf-report/template.rb:30:in `block in update_files'
.../rubyzip-2.3.2/lib/zip/entry_set.rb:38:in `block in each'
.../rubyzip-2.3.2/lib/zip/entry_set.rb:37:in `each'
.../rubyzip-2.3.2/lib/zip/entry_set.rb:37:in `each'
.../rubyzip-2.3.2/lib/zip/central_directory.rb:185:in `each'
.../odf-report-0.7.2/lib/odf-report/template.rb:26:in `update_files'
.../odf-report-0.7.2/lib/odf-report/report.rb:58:in `block in generate'
.../odf-report-0.7.2/lib/odf-report/template.rb:20:in `block in update_content'
.../rubyzip-2.3.2/lib/zip/output_stream.rb:63:in `write_buffer'
.../odf-report-0.7.2/lib/odf-report/template.rb:18:in `update_content'
.../odf-report-0.7.2/lib/odf-report/report.rb:56:in `generate'

Footnotes

  1. https://github.com/sparklemotion/nokogiri/issues/2419

@hoeni
Copy link

hoeni commented Feb 18, 2022

Same Problem here (odf-report 0.7.2), results in same stack trace. 1.13.0 works fine, 1.13.1 fails with this.

@shanecav84
Copy link
Author

@sandrods This is preventing me from upgrading Nokogiri to patch a CVE GHSA-fq42-c5rg-92c2

@sandrods
Copy link
Owner

sandrods commented Feb 22, 2022 via email

@sandrods
Copy link
Owner

Well, pipes are part of CSS3 specifications, and are used to query using namespaces

https://www.w3.org/TR/selectors-3/#univnmsp

I'll have to look into it further. It may be a regression bug in Nokogiri, since it worked until 1.13.0.

I may need to translate these queries into xpath. Right now I have no clue.

Will keep you all posted. Any directions would be appreciated

sandrods added a commit that referenced this issue Feb 23, 2022
@sandrods
Copy link
Owner

sandrods commented Feb 23, 2022

I think I might have fixed it. My specs are green now.
Could you run a quick test using master to confirm, so I can release a new version?

@shanecav84
Copy link
Author

It's working for me. Thanks!

@sandrods
Copy link
Owner

closed by 1fb39e1

@hoeni
Copy link

hoeni commented Feb 24, 2022

Works like a charm for me. Thank you so much!

y-yagi added a commit to y-yagi/odf-report that referenced this issue Feb 27, 2022
According to the sandrods#120,
it seems it happened at v1.13.1.
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