nokogiri 1.13.3 → 1.13.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a9e9c98ef383eff954865accb42edd57b6521476c8f457e1d8530247e2bb9d5
4
- data.tar.gz: 5c949a7d6c384851830dd42703050431dd718ee2500387c3a88ba73dbaf69d18
3
+ metadata.gz: 111da6f69d040f9ac5c3573b0e03cdc5e09fb27c5d8ae8bc6e0bf70079dbcdb8
4
+ data.tar.gz: ccbda476379e696103cf61983df914c6b7312090b5905daccb3077f0a25e60ba
5
5
  SHA512:
6
- metadata.gz: 05451ca1438a1bde88ab4c210d0d5a460c205c365d1853a554e2eb5b6736933dfd64a487f6e1db4a0002f517d92da22ad83e5f92b40a0639c6286f544b93fc8b
7
- data.tar.gz: 290e2a97df760bcdfb91c3994a1062cb49ffd9f63722bf3608db2b9a2e45f1dffc14e46f2105c74133bc8bb134a77caddf8a6092d251419e904354e4580db082
6
+ metadata.gz: bbf69d93304d43cf38667fe66e84caf84b8ca4b89a3ec3d8139fe2f986c10bc5b971d4ed97870601be2ed92b6e748593fea02b89e7f6e2deed09c5a604d2d101
7
+ data.tar.gz: 4a2a6b55fd87f8b4adb5e8687959d9f0c88334638ca2746761155b0214095ce14d648482833b8f80a59b94a54d29e26d9cae4caacda57b772fe00804de6cdabe
data/dependencies.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  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
5
5
 
6
6
  libxslt:
7
7
  version: "1.1.35"
@@ -9,8 +9,8 @@ libxslt:
9
9
  # sha-256 hash provided in https://download.gnome.org/sources/libxslt/1.1/libxslt-1.1.35.sha256sum
10
10
 
11
11
  zlib:
12
- version: "1.2.11"
13
- sha256: "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1"
12
+ version: "1.2.12"
13
+ sha256: "91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9"
14
14
  # SHA-256 hash provided on http://zlib.net/
15
15
 
16
16
  libiconv:
@@ -382,6 +382,7 @@ def iconv_configure_flags
382
382
  ["iconv", "opt"].each do |target|
383
383
  config = preserving_globals { dir_config(target) }
384
384
  next unless config.any? && try_link_iconv("--with-#{target}-* flags") { dir_config(target) }
385
+
385
386
  idirs, ldirs = config.map do |dirs|
386
387
  Array(dirs).flat_map do |dir|
387
388
  dir.split(File::PATH_SEPARATOR)
@@ -715,14 +716,6 @@ else
715
716
  execute("configure",
716
717
  ["env", "CHOST=#{host}", "CFLAGS=#{cflags}", "./configure", "--static", configure_prefix])
717
718
  end
718
-
719
- def compile
720
- if /darwin/.match?(host)
721
- execute("compile", "make AR=#{host}-libtool")
722
- else
723
- super
724
- end
725
- end
726
719
  end
727
720
  end
728
721
  end
@@ -19,9 +19,8 @@ parse_memory(VALUE klass, VALUE data, VALUE encoding)
19
19
  {
20
20
  htmlParserCtxtPtr ctxt;
21
21
 
22
- if (NIL_P(data)) {
23
- rb_raise(rb_eArgError, "data cannot be nil");
24
- }
22
+ Check_Type(data, T_STRING);
23
+
25
24
  if (!(int)RSTRING_LEN(data)) {
26
25
  rb_raise(rb_eRuntimeError, "data cannot be empty");
27
26
  }
@@ -2,6 +2,8 @@
2
2
 
3
3
  VALUE cNokogiriXmlSaxParserContext ;
4
4
 
5
+ static ID id_read;
6
+
5
7
  static void
6
8
  deallocate(xmlParserCtxtPtr ctxt)
7
9
  {
@@ -26,6 +28,10 @@ parse_io(VALUE klass, VALUE io, VALUE encoding)
26
28
  xmlParserCtxtPtr ctxt;
27
29
  xmlCharEncoding enc = (xmlCharEncoding)NUM2INT(encoding);
28
30
 
31
+ if (!rb_respond_to(io, id_read)) {
32
+ rb_raise(rb_eTypeError, "argument expected to respond to :read");
33
+ }
34
+
29
35
  ctxt = xmlCreateIOParserCtxt(NULL, NULL,
30
36
  (xmlInputReadCallback)noko_io_read,
31
37
  (xmlInputCloseCallback)noko_io_close,
@@ -62,9 +68,8 @@ parse_memory(VALUE klass, VALUE data)
62
68
  {
63
69
  xmlParserCtxtPtr ctxt;
64
70
 
65
- if (NIL_P(data)) {
66
- rb_raise(rb_eArgError, "data cannot be nil");
67
- }
71
+ Check_Type(data, T_STRING);
72
+
68
73
  if (!(int)RSTRING_LEN(data)) {
69
74
  rb_raise(rb_eRuntimeError, "data cannot be empty");
70
75
  }
@@ -278,4 +283,6 @@ noko_init_xml_sax_parser_context()
278
283
  rb_define_method(cNokogiriXmlSaxParserContext, "recovery", get_recovery, 0);
279
284
  rb_define_method(cNokogiriXmlSaxParserContext, "line", line, 0);
280
285
  rb_define_method(cNokogiriXmlSaxParserContext, "column", column, 0);
286
+
287
+ id_read = rb_intern("read");
281
288
  }
@@ -24,12 +24,14 @@ module Nokogiri
24
24
  # Get the css selector in +string+ from the cache
25
25
  def [](string)
26
26
  return nil unless cache_on?
27
+
27
28
  @mutex.synchronize { @cache[string] }
28
29
  end
29
30
 
30
31
  # Set the css selector in +string+ in the cache to +value+
31
32
  def []=(string, value)
32
33
  return value unless cache_on?
34
+
33
35
  @mutex.synchronize { @cache[string] = value }
34
36
  end
35
37
 
@@ -125,8 +125,9 @@ module Nokogiri
125
125
  private :set_metadata_element
126
126
 
127
127
  ####
128
- # Serialize Node using +options+. Save options can also be set using a
129
- # block. See SaveOptions.
128
+ # Serialize Node using +options+. Save options can also be set using a block.
129
+ #
130
+ # See also Nokogiri::XML::Node::SaveOptions and Node@Serialization+and+Generating+Output.
130
131
  #
131
132
  # These two statements are equivalent:
132
133
  #
@@ -241,6 +242,7 @@ module Nokogiri
241
242
 
242
243
  def start_element(name, attrs = [])
243
244
  return unless name == "meta"
245
+
244
246
  attr = Hash[attrs]
245
247
  (charset = attr["charset"]) &&
246
248
  (@encoding = charset)
@@ -266,7 +268,7 @@ module Nokogiri
266
268
  end
267
269
 
268
270
  def self.detect_encoding(chunk)
269
- (m = chunk.match(/\A(<\?xml[ \t\r\n]+[^>]*>)/)) &&
271
+ (m = chunk.match(/\A(<\?xml[ \t\r\n][^>]*>)/)) &&
270
272
  (return Nokogiri.XML(m[1]).encoding)
271
273
 
272
274
  if Nokogiri.jruby?
@@ -28,8 +28,9 @@ module Nokogiri
28
28
  ###
29
29
  # Parse html stored in +data+ using +encoding+
30
30
  def parse_memory(data, encoding = "UTF-8")
31
- raise ArgumentError unless data
31
+ raise TypeError unless String === data
32
32
  return if data.empty?
33
+
33
34
  ctx = ParserContext.memory(data, encoding)
34
35
  yield ctx if block_given?
35
36
  ctx.parse_with(self)
@@ -51,6 +52,7 @@ module Nokogiri
51
52
  raise ArgumentError unless filename
52
53
  raise Errno::ENOENT unless File.exist?(filename)
53
54
  raise Errno::EISDIR if File.directory?(filename)
55
+
54
56
  ctx = ParserContext.file(filename, encoding)
55
57
  yield ctx if block_given?
56
58
  ctx.parse_with(self)
@@ -39,16 +39,19 @@ module Nokogiri
39
39
  unless string_or_io.respond_to?(:read) || string_or_io.respond_to?(:to_str)
40
40
  raise ArgumentError, "not a string or IO object"
41
41
  end
42
+
42
43
  do_parse(string_or_io, url, encoding, options)
43
44
  end
44
45
 
45
46
  def self.read_io(io, url = nil, encoding = nil, **options)
46
47
  raise ArgumentError, "io object doesn't respond to :read" unless io.respond_to?(:read)
48
+
47
49
  do_parse(io, url, encoding, options)
48
50
  end
49
51
 
50
52
  def self.read_memory(string, url = nil, encoding = nil, **options)
51
53
  raise ArgumentError, "string object doesn't respond to :to_str" unless string.respond_to?(:to_str)
54
+
52
55
  do_parse(string, url, encoding, options)
53
56
  end
54
57
 
@@ -27,6 +27,7 @@ module Nokogiri
27
27
  module Node
28
28
  def inner_html(options = {})
29
29
  return super(options) unless document.is_a?(HTML5::Document)
30
+
30
31
  result = options[:preserve_newline] && HTML5.prepend_newline?(self) ? +"\n" : +""
31
32
  result << children.map { |child| child.to_html(options) }.join
32
33
  result
@@ -34,6 +35,7 @@ module Nokogiri
34
35
 
35
36
  def write_to(io, *options)
36
37
  return super(io, *options) unless document.is_a?(HTML5::Document)
38
+
37
39
  options = options.first.is_a?(Hash) ? options.shift : {}
38
40
  encoding = options[:encoding] || options[0]
39
41
  if Nokogiri.jruby?
@@ -64,6 +66,7 @@ module Nokogiri
64
66
 
65
67
  def fragment(tags)
66
68
  return super(tags) unless document.is_a?(HTML5::Document)
69
+
67
70
  DocumentFragment.new(document, tags, self)
68
71
  end
69
72
 
@@ -76,6 +79,7 @@ module Nokogiri
76
79
  # actually create the xml namespace if it doesn't exist already.
77
80
  def add_child_node_and_reparent_attrs(node)
78
81
  return super(node) unless document.is_a?(HTML5::Document)
82
+
79
83
  # I'm not sure what this method is supposed to do. Reparenting
80
84
  # namespaces is handled by libxml2, including child namespaces which
81
85
  # this method wouldn't handle.
@@ -468,6 +468,7 @@ module Nokogiri
468
468
 
469
469
  def self.prepend_newline?(node)
470
470
  return false unless ["pre", "textarea", "listing"].include?(node.name) && !node.children.empty?
471
+
471
472
  first_child = node.children[0]
472
473
  first_child.text? && first_child.content.start_with?("\n")
473
474
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Nokogiri
4
4
  # The version of Nokogiri you are using
5
- VERSION = "1.13.3"
5
+ VERSION = "1.13.6"
6
6
  end
@@ -191,6 +191,7 @@ module Nokogiri
191
191
  def self.uses_libxml?(requirement = nil)
192
192
  return false unless VersionInfo.instance.libxml2?
193
193
  return true unless requirement
194
+
194
195
  Gem::Requirement.new(requirement).satisfied_by?(VersionInfo.instance.loaded_libxml_version)
195
196
  end
196
197
 
@@ -363,6 +363,7 @@ module Nokogiri
363
363
 
364
364
  @parent.ancestors.each do |a|
365
365
  next if a == doc
366
+
366
367
  @ns = a.namespace_definitions.find { |x| x.prefix == ns.to_s }
367
368
  return self if @ns
368
369
  end
@@ -407,6 +408,7 @@ module Nokogiri
407
408
  if node.namespace.nil?
408
409
  raise ArgumentError, "Namespace #{@ns[:pending]} has not been defined"
409
410
  end
411
+
410
412
  @ns = nil
411
413
  end
412
414
 
@@ -321,6 +321,7 @@ module Nokogiri
321
321
  # the document or +nil+ when there is no DTD.
322
322
  def validate
323
323
  return nil unless internal_subset
324
+
324
325
  internal_subset.validate(self)
325
326
  end
326
327
 
@@ -353,8 +354,10 @@ module Nokogiri
353
354
  # Apply any decorators to +node+
354
355
  def decorate(node)
355
356
  return unless @decorators
357
+
356
358
  @decorators.each do |klass, list|
357
359
  next unless node.is_a?(klass)
360
+
358
361
  list.each { |moodule| node.extend(moodule) }
359
362
  end
360
363
  end
@@ -380,9 +383,11 @@ module Nokogiri
380
383
 
381
384
  def add_child(node_or_tags)
382
385
  raise "A document may not have multiple root nodes." if (root && root.name != "nokogiri_text_wrapper") && !(node_or_tags.comment? || node_or_tags.processing_instruction?)
386
+
383
387
  node_or_tags = coerce(node_or_tags)
384
388
  if node_or_tags.is_a?(XML::NodeSet)
385
389
  raise "A document may not have multiple root nodes." if node_or_tags.size > 1
390
+
386
391
  super(node_or_tags.first)
387
392
  else
388
393
  super
@@ -4,7 +4,8 @@ module Nokogiri
4
4
  module XML
5
5
  class Node
6
6
  ###
7
- # Save options for serializing nodes
7
+ # Save options for serializing nodes.
8
+ # See the method group entitled Node@Serialization+and+Generating+Output for usage.
8
9
  class SaveOptions
9
10
  # Format serialized xml
10
11
  FORMAT = 1
@@ -124,7 +124,7 @@ module Nokogiri
124
124
  # [Returns] Nokogiri::XML::Node
125
125
  #
126
126
  def initialize(name, document)
127
- # This is intentionally empty.
127
+ # This is intentionally empty, and sets the method signature for subclasses.
128
128
  end
129
129
 
130
130
  ###
@@ -163,6 +163,7 @@ module Nokogiri
163
163
  if (first = children.first)
164
164
  # Mimic the error add_child would raise.
165
165
  raise "Document already has a root node" if document? && !(node_or_tags.comment? || node_or_tags.processing_instruction?)
166
+
166
167
  first.__send__(:add_sibling, :previous, node_or_tags)
167
168
  else
168
169
  add_child(node_or_tags)
@@ -1072,6 +1073,7 @@ module Nokogiri
1072
1073
  # nil on XML documents and on unknown tags.
1073
1074
  def description
1074
1075
  return nil if document.xml?
1076
+
1075
1077
  Nokogiri::HTML4::ElementDescription[name]
1076
1078
  end
1077
1079
 
@@ -1119,6 +1121,7 @@ module Nokogiri
1119
1121
 
1120
1122
  while parents.last.respond_to?(:parent)
1121
1123
  break unless (ctx_parent = parents.last.parent)
1124
+
1122
1125
  parents << ctx_parent
1123
1126
  end
1124
1127
 
@@ -1150,6 +1153,7 @@ module Nokogiri
1150
1153
  def ==(other)
1151
1154
  return false unless other
1152
1155
  return false unless other.respond_to?(:pointer_id)
1156
+
1153
1157
  pointer_id == other.pointer_id
1154
1158
  end
1155
1159
 
@@ -1159,14 +1163,16 @@ module Nokogiri
1159
1163
  def <=>(other)
1160
1164
  return nil unless other.is_a?(Nokogiri::XML::Node)
1161
1165
  return nil unless document == other.document
1166
+
1162
1167
  compare(other)
1163
1168
  end
1164
1169
 
1165
1170
  # :section: Serialization and Generating Output
1166
1171
 
1167
1172
  ###
1168
- # Serialize Node using +options+. Save options can also be set using a
1169
- # block. See SaveOptions.
1173
+ # Serialize Node using +options+. Save options can also be set using a block.
1174
+ #
1175
+ # See also Nokogiri::XML::Node::SaveOptions and Node@Serialization+and+Generating+Output.
1170
1176
  #
1171
1177
  # These two statements are equivalent:
1172
1178
  #
@@ -27,6 +27,7 @@ module Nokogiri
27
27
  # Get the first element of the NodeSet.
28
28
  def first(n = nil)
29
29
  return self[0] unless n
30
+
30
31
  list = []
31
32
  [n, length].min.times { |i| list << self[i] }
32
33
  list
@@ -304,6 +305,7 @@ module Nokogiri
304
305
  # the set is empty
305
306
  def pop
306
307
  return nil if length == 0
308
+
307
309
  delete(last)
308
310
  end
309
311
 
@@ -312,6 +314,7 @@ module Nokogiri
312
314
  # +nil+ if the set is empty.
313
315
  def shift
314
316
  return nil if length == 0
317
+
315
318
  delete(first)
316
319
  end
317
320
 
@@ -322,6 +325,7 @@ module Nokogiri
322
325
  def ==(other)
323
326
  return false unless other.is_a?(Nokogiri::XML::NodeSet)
324
327
  return false unless length == other.length
328
+
325
329
  each_with_index do |node, i|
326
330
  return false unless node == other[i]
327
331
  end
@@ -89,6 +89,7 @@ module Nokogiri
89
89
 
90
90
  constants.each do |constant|
91
91
  next if constant.to_sym == :STRICT
92
+
92
93
  class_eval %{
93
94
  def #{constant.downcase}
94
95
  @options |= #{constant}
@@ -3,7 +3,7 @@
3
3
  module Nokogiri
4
4
  module XML
5
5
  class ProcessingInstruction < Node
6
- def initialize(document, name, content)
6
+ def initialize(document, name, content) # rubocop:disable Style/RedundantInitialize
7
7
  end
8
8
  end
9
9
  end
@@ -101,6 +101,7 @@ module Nokogiri
101
101
  raise ArgumentError unless filename
102
102
  raise Errno::ENOENT unless File.exist?(filename)
103
103
  raise Errno::EISDIR if File.directory?(filename)
104
+
104
105
  ctx = ParserContext.file(filename)
105
106
  yield ctx if block_given?
106
107
  ctx.parse_with(self)
@@ -64,6 +64,7 @@ module Nokogiri
64
64
 
65
65
  def location_to_s
66
66
  return nil if nil_or_zero?(line) && nil_or_zero?(column)
67
+
67
68
  "#{line}:#{column}"
68
69
  end
69
70
  end
data/lib/nokogiri/xml.rb CHANGED
@@ -27,6 +27,7 @@ module Nokogiri
27
27
  if string_or_io.respond_to?(:read)
28
28
  return Reader.from_io(string_or_io, url, encoding, options.to_i)
29
29
  end
30
+
30
31
  Reader.from_memory(string_or_io, url, encoding, options.to_i)
31
32
  end
32
33
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.3
4
+ version: 1.13.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Dalessio
@@ -20,7 +20,7 @@ authors:
20
20
  autorequire:
21
21
  bindir: bin
22
22
  cert_chain: []
23
- date: 2022-02-22 00:00:00.000000000 Z
23
+ date: 2022-05-08 00:00:00.000000000 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mini_portile2
@@ -182,14 +182,20 @@ dependencies:
182
182
  requirements:
183
183
  - - "~>"
184
184
  - !ruby/object:Gem::Version
185
- version: '1.23'
185
+ version: '1.28'
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: 1.28.2
186
189
  type: :development
187
190
  prerelease: false
188
191
  version_requirements: !ruby/object:Gem::Requirement
189
192
  requirements:
190
193
  - - "~>"
191
194
  - !ruby/object:Gem::Version
192
- version: '1.23'
195
+ version: '1.28'
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: 1.28.2
193
199
  - !ruby/object:Gem::Dependency
194
200
  name: rubocop-minitest
195
201
  requirement: !ruby/object:Gem::Requirement
@@ -492,9 +498,8 @@ files:
492
498
  - patches/libxml2/0006-update-automake-files-for-arm64.patch
493
499
  - patches/libxml2/0008-htmlParseComment-handle-abruptly-closed-comments.patch
494
500
  - patches/libxml2/0009-allow-wildcard-namespaces.patch
495
- - patches/libxml2/0010-Revert-Different-approach-to-fix-quadratic-behavior.patch
496
501
  - patches/libxslt/0001-update-automake-files-for-arm64.patch
497
- - ports/archives/libxml2-2.9.13.tar.xz
502
+ - ports/archives/libxml2-2.9.14.tar.xz
498
503
  - ports/archives/libxslt-1.1.35.tar.xz
499
504
  homepage: https://nokogiri.org
500
505
  licenses:
@@ -1,45 +0,0 @@
1
- From ddc5f3d22644e0f6fbcc20541c86825757ffee62 Mon Sep 17 00:00:00 2001
2
- From: Mike Dalessio <mike.dalessio@gmail.com>
3
- Date: Mon, 21 Feb 2022 18:27:45 -0500
4
- Subject: [PATCH] Revert "Different approach to fix quadratic behavior in HTML
5
- push parser"
6
-
7
- This reverts commit 798bdf13f6964a650b9a0b7b4b3a769f6f1d509a.
8
- ---
9
- HTMLparser.c | 14 +-------------
10
- 1 file changed, 1 insertion(+), 13 deletions(-)
11
-
12
- diff --git a/HTMLparser.c b/HTMLparser.c
13
- index eba2d7c..c0b8119 100644
14
- --- a/HTMLparser.c
15
- +++ b/HTMLparser.c
16
- @@ -3960,25 +3960,13 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
17
- htmlParseErr(ctxt, XML_ERR_NAME_REQUIRED,
18
- "htmlParseStartTag: invalid element name\n",
19
- NULL, NULL);
20
- - /*
21
- - * The recovery code is disabled for now as it can result in
22
- - * quadratic behavior with the push parser. htmlParseStartTag
23
- - * must consume all content up to the final '>' in order to avoid
24
- - * rescanning for this terminator.
25
- - *
26
- - * For a proper fix in line with HTML5, htmlParseStartTag and
27
- - * htmlParseElement should only be called when there's an ASCII
28
- - * alpha character following the initial '<'. Otherwise, the '<'
29
- - * should be emitted as text (unless followed by '!', '/' or '?').
30
- - */
31
- -#if 0
32
- /* if recover preserve text on classic misconstructs */
33
- if ((ctxt->recovery) && ((IS_BLANK_CH(CUR)) || (CUR == '<') ||
34
- (CUR == '=') || (CUR == '>') || (((CUR >= '0') && (CUR <= '9'))))) {
35
- htmlParseCharDataInternal(ctxt, '<');
36
- return(-1);
37
- }
38
- -#endif
39
- +
40
-
41
- /* Dump the bogus tag like browsers do */
42
- while ((CUR != 0) && (CUR != '>') &&
43
- --
44
- 2.31.0
45
-
Binary file