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

fix: CSS queries with xpath-incompatible pseudo-classes raise an exception at query parse time #3197

Merged
merged 3 commits into from
May 24, 2024

Commits on May 24, 2024

  1. Configuration menu
    Copy the full SHA
    0aa46e1 View commit details
    Browse the repository at this point in the history
  2. refactor css/tokenizer.rb

    - use parens more intentionally in the rexical macros
    - rename the CSS ID token macro from `name` to `charref` to match XPath CharRef
    - extract a `name` macro that matches XPath Name
    flavorjones committed May 24, 2024
    Configuration menu
    Copy the full SHA
    3d3238c View commit details
    Browse the repository at this point in the history
  3. fix: raise CSS::SyntaxError if a pseudo-class is not an XPath Name

    Some pseudo-classes cannot be converted into an XPath function name,
    and libxml2 will raise an Nokogiri::XML::XPath::SyntaxError at
    query-time:
    
        nokogiri/xml/searchable.rb:238:in `evaluate': ERROR: Invalid expression: //*:div[nokogiri:-moz-drag-over(.)] (Nokogiri::XML::XPath::SyntaxError)
    
    This change moves the error from query-time to parse-time, in the
    hopes that this is more rescuable (and the error is more descriptive):
    
        nokogiri/css/parser_extras.rb:86:in `on_error': unexpected '-' after ':' (Nokogiri::CSS::SyntaxError)
    
    Closes #3193
    flavorjones committed May 24, 2024
    Configuration menu
    Copy the full SHA
    d3a60cb View commit details
    Browse the repository at this point in the history