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

dep: update libxml2 to v2.9.14 (v1.13.x branch) #2527

Merged
merged 5 commits into from May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 29 additions & 18 deletions .rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-01-03 20:31:05 UTC using RuboCop version 1.24.1.
# on 2022-05-04 15:17:01 UTC using RuboCop version 1.28.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -22,16 +22,21 @@ Lint/MissingSuper:
- 'lib/nokogiri/xml/document_fragment.rb'
- 'lib/nokogiri/xml/processing_instruction.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
Lint/RedundantCopDisableDirective:
Exclude:
- 'lib/nokogiri/xml/processing_instruction.rb'

# Offense count: 2
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier:
Exclude:
- 'lib/nokogiri/css/xpath_visitor.rb'
- 'lib/nokogiri/html5.rb'
- 'lib/nokogiri/html5/document.rb'

# Offense count: 18
# Offense count: 17
# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 5
Expand All @@ -50,8 +55,8 @@ Performance/CollectionLiteralInLoop:
- 'test/xml/test_dtd_encoding.rb'
- 'test/xml/test_node_reparenting.rb'

# Offense count: 11
# Cop supports --auto-correct.
# Offense count: 12
# This cop supports safe auto-correction (--auto-correct).
Performance/StringIdentifierArgument:
Exclude:
- 'lib/nokogiri/html5.rb'
Expand All @@ -60,20 +65,14 @@ Performance/StringIdentifierArgument:
- 'test/test_memory_leak.rb'
- 'test/xml/test_builder.rb'

# Offense count: 1
# Cop supports --auto-correct.
Performance/StringInclude:
Exclude:
- 'lib/nokogiri/css/xpath_visitor.rb'

# Offense count: 2
# Cop supports --auto-correct.
# This cop supports safe auto-correction (--auto-correct).
Performance/TimesMap:
Exclude:
- 'test/html5/test_nokogumbo.rb'

# Offense count: 6
# Cop supports --auto-correct.
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Expand All @@ -85,14 +84,26 @@ Style/ClassAndModuleChildren:
- 'test/xml/sax/test_parser.rb'
- 'test/xml/sax/test_push_parser.rb'

# Offense count: 17
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowedVars.
Style/FetchEnvVar:
Exclude:
- 'ext/nokogiri/extconf.rb'
- 'rakelib/debug.rake'
- 'rakelib/extensions.rake'
- 'rakelib/rdoc.rake'
- 'test/helper.rb'

# Offense count: 2
Style/MissingRespondToMissing:
Exclude:
- 'lib/nokogiri/xml/builder.rb'

# Offense count: 78
# Cop supports --auto-correct.
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# Offense count: 81
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
# URISchemes: http, https
# AllowedPatterns: \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z)
Layout/LineLength:
Max: 250
6 changes: 3 additions & 3 deletions dependencies.yml
@@ -1,7 +1,7 @@
libxml2:
version: "2.9.13"
sha256: "276130602d12fe484ecc03447ee5e759d0465558fbc9d6bd144e3745306ebf0e"
# sha-256 hash provided in https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.13.sha256sum
version: "2.9.14"
sha256: "60d74a257d1ccec0475e749cba2f21559e48139efba6ff28224357c7c798dfee"
# sha-256 hash provided in https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.14.sha256sum

libxslt:
version: "1.1.35"
Expand Down
4 changes: 2 additions & 2 deletions lib/nokogiri/xml/node.rb
Expand Up @@ -123,8 +123,8 @@ class Node
# [Yields] Nokogiri::XML::Node
# [Returns] Nokogiri::XML::Node
#
def initialize(name, document) # rubocop:disable Style/RedundantInitialize
# This is intentionally empty.
def initialize(name, document)
# This is intentionally empty, and sets the method signature for subclasses.
end

###
Expand Down
2 changes: 1 addition & 1 deletion nokogiri.gemspec
Expand Up @@ -330,7 +330,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency("rake-compiler-dock", "~> 1.2")
spec.add_development_dependency("rdoc", "~> 6.3")
spec.add_development_dependency("rexical", "~> 1.0.7")
spec.add_development_dependency("rubocop", "~> 1.23")
spec.add_development_dependency("rubocop", "~> 1.28", ">= 1.28.2")
spec.add_development_dependency("rubocop-minitest", "~> 0.17")
spec.add_development_dependency("rubocop-performance", "~> 1.12")
spec.add_development_dependency("rubocop-rake", "~> 0.6")
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions rakelib/extensions.rake
Expand Up @@ -373,6 +373,7 @@ if java?
end
else
require "rake/extensiontask"
require "yaml"

dependencies = YAML.load_file("dependencies.yml")

Expand Down
25 changes: 24 additions & 1 deletion test/html4/test_comments.rb
Expand Up @@ -173,7 +173,7 @@ class TestComment < Nokogiri::TestCase
let(:body) { doc.at_css("body") }
let(:subject) { doc.at_css("div#under-test") }

if Nokogiri.uses_libxml?
if Nokogiri.uses_libxml?("<=2.9.13")
it "ignores up to the next '>'" do # NON-COMPLIANT
assert_equal 2, body.children.length
assert_equal body.children[0], subject
Expand All @@ -183,10 +183,33 @@ class TestComment < Nokogiri::TestCase
assert_predicate body.children[1], :text?
assert_equal "-->hello", body.children[1].content
end
elsif Nokogiri.uses_libxml?
it "parses as pcdata" do # NON-COMPLIANT
assert_equal 1, body.children.length
assert_equal subject, body.children.first

assert_equal 3, subject.children.length
subject.children[0].tap do |child|
assert_predicate(child, :text?)
assert_equal("<! comment ", child.content)
end
subject.children[1].tap do |child|
assert_predicate(child, :element?)
assert_equal("div", child.name)
assert_equal("inner content", child.content)
end
subject.children[2].tap do |child|
assert_predicate(child, :text?)
assert_equal("-->hello", child.content)
end
end
end

if Nokogiri.jruby?
it "ignores up to the next '-->'" do # NON-COMPLIANT
assert_equal 1, body.children.length
assert_equal subject, body.children.first

assert_equal 1, subject.children.length
assert_predicate subject.children[0], :text?
assert_equal "hello", subject.children[0].content
Expand Down
25 changes: 16 additions & 9 deletions test/html4/test_document.rb
Expand Up @@ -801,18 +801,25 @@ def test_leaking_dtd_nodes_after_internal_subset_removal

it "skips to the next start tag" do
# see https://github.com/sparklemotion/nokogiri/issues/2461 for why we're testing this edge case
if Nokogiri.uses_libxml?(">= 2.9.13")
skip_unless_libxml2_patch("0010-Revert-Different-approach-to-fix-quadratic-behavior.patch")
end

doc = Nokogiri::HTML4.parse(input)
body = doc.at_xpath("//body")

expected_error_snippet = Nokogiri.uses_libxml? ? "invalid element name" : "Missing start element name"
assert_includes(doc.errors.first.to_s, expected_error_snippet)

assert_equal("this < that", body.children.first.text, body.to_html)
assert_equal(["div", "div"], body.children.map(&:name), body.to_html)
if Nokogiri.uses_libxml?("= 2.9.13")
# <body><div>this <div>second element</div></div></body>
assert_equal(1, body.children.length)
body.children.first.tap do |div|
assert_equal(2, div.children.length)
assert_equal("this ", div.children[0].content)
assert_equal("div", div.children[1].name)
assert_equal("second element", div.children[1].content)
end
else
# <body><div>this &lt; that</div><div>second element</div></body>
assert_equal(2, body.children.length)
assert_equal(["div", "div"], body.children.map(&:name), body.to_html)
assert_equal("this < that", body.children[0].text, body.to_html)
assert_equal("second element", body.children[1].text, body.to_html)
end
end
end

Expand Down
8 changes: 1 addition & 7 deletions test/test_version.rb
Expand Up @@ -60,13 +60,7 @@ def test_version_info_for_libxml
major = Regexp.last_match(1).to_i
minor = Regexp.last_match(2).to_i
bug = Regexp.last_match(3).to_i
if RbConfig::CONFIG["target_os"].include?("freebsd13") && Nokogiri::VersionInfo.instance.libxml2_using_system?
pending("https://github.com/sparklemotion/nokogiri/issues/2506") do
assert_equal("#{major}.#{minor}.#{bug}", Nokogiri::VERSION_INFO["libxml"]["loaded"])
end
else
assert_equal("#{major}.#{minor}.#{bug}", Nokogiri::VERSION_INFO["libxml"]["loaded"])
end
assert_equal("#{major}.#{minor}.#{bug}", Nokogiri::VERSION_INFO["libxml"]["loaded"])

assert(version_info["libxml"].key?("iconv_enabled"))
assert(version_info["libxslt"].key?("datetime_enabled"))
Expand Down