Skip to content

Commit c519a47

Browse files
authored
Merge pull request #2527 from sparklemotion/2525-update-libxml-2_9_14-v1_13_x
dep: update libxml2 to v2.9.14 (v1.13.x branch)
2 parents 4e2c4b2 + 66c2886 commit c519a47

9 files changed

+77
-86
lines changed

.rubocop_todo.yml

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2022-01-03 20:31:05 UTC using RuboCop version 1.24.1.
3+
# on 2022-05-04 15:17:01 UTC using RuboCop version 1.28.2.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -22,16 +22,21 @@ Lint/MissingSuper:
2222
- 'lib/nokogiri/xml/document_fragment.rb'
2323
- 'lib/nokogiri/xml/processing_instruction.rb'
2424

25-
# Offense count: 4
26-
# Cop supports --auto-correct.
25+
# Offense count: 1
26+
# This cop supports safe auto-correction (--auto-correct).
27+
Lint/RedundantCopDisableDirective:
28+
Exclude:
29+
- 'lib/nokogiri/xml/processing_instruction.rb'
30+
31+
# Offense count: 2
32+
# This cop supports safe auto-correction (--auto-correct).
2733
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
2834
Lint/UselessAccessModifier:
2935
Exclude:
30-
- 'lib/nokogiri/css/xpath_visitor.rb'
3136
- 'lib/nokogiri/html5.rb'
3237
- 'lib/nokogiri/html5/document.rb'
3338

34-
# Offense count: 18
39+
# Offense count: 17
3540
# Configuration parameters: CountBlocks.
3641
Metrics/BlockNesting:
3742
Max: 5
@@ -50,8 +55,8 @@ Performance/CollectionLiteralInLoop:
5055
- 'test/xml/test_dtd_encoding.rb'
5156
- 'test/xml/test_node_reparenting.rb'
5257

53-
# Offense count: 11
54-
# Cop supports --auto-correct.
58+
# Offense count: 12
59+
# This cop supports safe auto-correction (--auto-correct).
5560
Performance/StringIdentifierArgument:
5661
Exclude:
5762
- 'lib/nokogiri/html5.rb'
@@ -60,20 +65,14 @@ Performance/StringIdentifierArgument:
6065
- 'test/test_memory_leak.rb'
6166
- 'test/xml/test_builder.rb'
6267

63-
# Offense count: 1
64-
# Cop supports --auto-correct.
65-
Performance/StringInclude:
66-
Exclude:
67-
- 'lib/nokogiri/css/xpath_visitor.rb'
68-
6968
# Offense count: 2
70-
# Cop supports --auto-correct.
69+
# This cop supports safe auto-correction (--auto-correct).
7170
Performance/TimesMap:
7271
Exclude:
7372
- 'test/html5/test_nokogumbo.rb'
7473

7574
# Offense count: 6
76-
# Cop supports --auto-correct.
75+
# This cop supports safe auto-correction (--auto-correct).
7776
# Configuration parameters: EnforcedStyle.
7877
# SupportedStyles: nested, compact
7978
Style/ClassAndModuleChildren:
@@ -85,14 +84,26 @@ Style/ClassAndModuleChildren:
8584
- 'test/xml/sax/test_parser.rb'
8685
- 'test/xml/sax/test_push_parser.rb'
8786

87+
# Offense count: 17
88+
# This cop supports safe auto-correction (--auto-correct).
89+
# Configuration parameters: AllowedVars.
90+
Style/FetchEnvVar:
91+
Exclude:
92+
- 'ext/nokogiri/extconf.rb'
93+
- 'rakelib/debug.rake'
94+
- 'rakelib/extensions.rake'
95+
- 'rakelib/rdoc.rake'
96+
- 'test/helper.rb'
97+
8898
# Offense count: 2
8999
Style/MissingRespondToMissing:
90100
Exclude:
91101
- 'lib/nokogiri/xml/builder.rb'
92102

93-
# Offense count: 78
94-
# Cop supports --auto-correct.
95-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
103+
# Offense count: 81
104+
# This cop supports safe auto-correction (--auto-correct).
105+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
96106
# URISchemes: http, https
107+
# 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)
97108
Layout/LineLength:
98109
Max: 250

dependencies.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
libxml2:
2-
version: "2.9.13"
3-
sha256: "276130602d12fe484ecc03447ee5e759d0465558fbc9d6bd144e3745306ebf0e"
4-
# sha-256 hash provided in https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.13.sha256sum
2+
version: "2.9.14"
3+
sha256: "60d74a257d1ccec0475e749cba2f21559e48139efba6ff28224357c7c798dfee"
4+
# sha-256 hash provided in https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.14.sha256sum
55

66
libxslt:
77
version: "1.1.35"

lib/nokogiri/xml/node.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ class Node
123123
# [Yields] Nokogiri::XML::Node
124124
# [Returns] Nokogiri::XML::Node
125125
#
126-
def initialize(name, document) # rubocop:disable Style/RedundantInitialize
127-
# This is intentionally empty.
126+
def initialize(name, document)
127+
# This is intentionally empty, and sets the method signature for subclasses.
128128
end
129129

130130
###

nokogiri.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ Gem::Specification.new do |spec|
330330
spec.add_development_dependency("rake-compiler-dock", "~> 1.2")
331331
spec.add_development_dependency("rdoc", "~> 6.3")
332332
spec.add_development_dependency("rexical", "~> 1.0.7")
333-
spec.add_development_dependency("rubocop", "~> 1.23")
333+
spec.add_development_dependency("rubocop", "~> 1.28", ">= 1.28.2")
334334
spec.add_development_dependency("rubocop-minitest", "~> 0.17")
335335
spec.add_development_dependency("rubocop-performance", "~> 1.12")
336336
spec.add_development_dependency("rubocop-rake", "~> 0.6")

patches/libxml2/0010-Revert-Different-approach-to-fix-quadratic-behavior.patch

Lines changed: 0 additions & 45 deletions
This file was deleted.

rakelib/extensions.rake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ if java?
373373
end
374374
else
375375
require "rake/extensiontask"
376+
require "yaml"
376377

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

test/html4/test_comments.rb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class TestComment < Nokogiri::TestCase
173173
let(:body) { doc.at_css("body") }
174174
let(:subject) { doc.at_css("div#under-test") }
175175

176-
if Nokogiri.uses_libxml?
176+
if Nokogiri.uses_libxml?("<=2.9.13")
177177
it "ignores up to the next '>'" do # NON-COMPLIANT
178178
assert_equal 2, body.children.length
179179
assert_equal body.children[0], subject
@@ -183,10 +183,33 @@ class TestComment < Nokogiri::TestCase
183183
assert_predicate body.children[1], :text?
184184
assert_equal "-->hello", body.children[1].content
185185
end
186+
elsif Nokogiri.uses_libxml?
187+
it "parses as pcdata" do # NON-COMPLIANT
188+
assert_equal 1, body.children.length
189+
assert_equal subject, body.children.first
190+
191+
assert_equal 3, subject.children.length
192+
subject.children[0].tap do |child|
193+
assert_predicate(child, :text?)
194+
assert_equal("<! comment ", child.content)
195+
end
196+
subject.children[1].tap do |child|
197+
assert_predicate(child, :element?)
198+
assert_equal("div", child.name)
199+
assert_equal("inner content", child.content)
200+
end
201+
subject.children[2].tap do |child|
202+
assert_predicate(child, :text?)
203+
assert_equal("-->hello", child.content)
204+
end
205+
end
186206
end
187207

188208
if Nokogiri.jruby?
189209
it "ignores up to the next '-->'" do # NON-COMPLIANT
210+
assert_equal 1, body.children.length
211+
assert_equal subject, body.children.first
212+
190213
assert_equal 1, subject.children.length
191214
assert_predicate subject.children[0], :text?
192215
assert_equal "hello", subject.children[0].content

test/html4/test_document.rb

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -801,18 +801,25 @@ def test_leaking_dtd_nodes_after_internal_subset_removal
801801

802802
it "skips to the next start tag" do
803803
# see https://github.com/sparklemotion/nokogiri/issues/2461 for why we're testing this edge case
804-
if Nokogiri.uses_libxml?(">= 2.9.13")
805-
skip_unless_libxml2_patch("0010-Revert-Different-approach-to-fix-quadratic-behavior.patch")
806-
end
807-
808804
doc = Nokogiri::HTML4.parse(input)
809805
body = doc.at_xpath("//body")
810806

811-
expected_error_snippet = Nokogiri.uses_libxml? ? "invalid element name" : "Missing start element name"
812-
assert_includes(doc.errors.first.to_s, expected_error_snippet)
813-
814-
assert_equal("this < that", body.children.first.text, body.to_html)
815-
assert_equal(["div", "div"], body.children.map(&:name), body.to_html)
807+
if Nokogiri.uses_libxml?("= 2.9.13")
808+
# <body><div>this <div>second element</div></div></body>
809+
assert_equal(1, body.children.length)
810+
body.children.first.tap do |div|
811+
assert_equal(2, div.children.length)
812+
assert_equal("this ", div.children[0].content)
813+
assert_equal("div", div.children[1].name)
814+
assert_equal("second element", div.children[1].content)
815+
end
816+
else
817+
# <body><div>this &lt; that</div><div>second element</div></body>
818+
assert_equal(2, body.children.length)
819+
assert_equal(["div", "div"], body.children.map(&:name), body.to_html)
820+
assert_equal("this < that", body.children[0].text, body.to_html)
821+
assert_equal("second element", body.children[1].text, body.to_html)
822+
end
816823
end
817824
end
818825

test/test_version.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,7 @@ def test_version_info_for_libxml
6060
major = Regexp.last_match(1).to_i
6161
minor = Regexp.last_match(2).to_i
6262
bug = Regexp.last_match(3).to_i
63-
if RbConfig::CONFIG["target_os"].include?("freebsd13") && Nokogiri::VersionInfo.instance.libxml2_using_system?
64-
pending("https://github.com/sparklemotion/nokogiri/issues/2506") do
65-
assert_equal("#{major}.#{minor}.#{bug}", Nokogiri::VERSION_INFO["libxml"]["loaded"])
66-
end
67-
else
68-
assert_equal("#{major}.#{minor}.#{bug}", Nokogiri::VERSION_INFO["libxml"]["loaded"])
69-
end
63+
assert_equal("#{major}.#{minor}.#{bug}", Nokogiri::VERSION_INFO["libxml"]["loaded"])
7064

7165
assert(version_info["libxml"].key?("iconv_enabled"))
7266
assert(version_info["libxslt"].key?("datetime_enabled"))

0 commit comments

Comments
 (0)