Skip to content

[bug] Nokogiri::XML::Document#css no longer matches namespaced XML attributes #3411

@stanhu

Description

@stanhu

Please describe the bug

I'm not sure if this is a bug, but I noticed when trying to upgrade from nokogiri v1.16.8 to v1.17.2, that this behavior changed:

require 'nokogiri'

body = <<-XML
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
  <ShortName>Test</ShortName>
  <Description>Search Test</Description>
  <InputEncoding>UTF-8</InputEncoding>
  <Image width="16" height="16" type="image/x-icon">http://test.host/favicon.ico</Image>
  <Url type="text/html" method="get" template="http://test.host/search?search={searchTerms}"/>
  <moz:SearchForm>http://test.host/search</moz:SearchForm>
</OpenSearchDescription>
XML

doc = Nokogiri::XML.parse(body)

puts doc.css('OpenSearchDescription *').map(&:name)

In nokogiri v1.16.8, this returned:

ShortName
Description
InputEncoding
Image
Url
SearchForm

In nokogiri v1.17.2, SearchForm is excluded:

ShortName
Description
InputEncoding
Image
Url

I see three commits in lib/nokogiri/xml/searchable.rb that might be relevant:

Is this intentional? Do I need to change my selector to handle this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions