Skip to content

Commit

Permalink
test: add coverage for xpath recursion depth fix
Browse files Browse the repository at this point in the history
Related to #2257
  • Loading branch information
flavorjones committed Jun 2, 2021
1 parent 3b3a152 commit f2c6f71
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/xml/test_xpath.rb
Expand Up @@ -470,6 +470,27 @@ def test_xpath_syntax_error
end
end

def test_huge_xpath_query
if Nokogiri.uses_libxml?("~>2.9.11") && !Nokogiri::VERSION_INFO["libxml"]["patches"]&.include?("0007-Fix-XPath-recursion-limit.patch")
skip("libxml2 under test is broken with respect to xpath query recusion depth")
end

# real world example
# from https://github.com/sparklemotion/nokogiri/issues/2257
query = File.read(File.join(ASSETS_DIR, 'huge-xpath-query.txt'))

doc = Nokogiri::XML::Document.parse("<root></root>")
handler = Class.new do
def seconds(context)
42
end
def add(context, rhs)
42
end
end
doc.xpath(query, {"ct" => "https://test.nokogiri.org/ct", "date" => "https://test.nokogiri.org/date"}, handler.new)
end

describe "nokogiri-builtin:css-class xpath function" do
before do
@doc = Nokogiri::HTML::Document.parse("<html></html>")
Expand Down

0 comments on commit f2c6f71

Please sign in to comment.