nokogiri 1.12.5 → 1.13.8
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 +4 -4
- data/Gemfile +2 -0
- data/README.md +9 -7
- data/bin/nokogiri +63 -50
- data/dependencies.yml +13 -64
- data/ext/nokogiri/extconf.rb +66 -44
- data/ext/nokogiri/gumbo.c +1 -1
- data/ext/nokogiri/html4_sax_parser_context.c +2 -3
- data/ext/nokogiri/nokogiri.h +8 -0
- data/ext/nokogiri/xml_attr.c +2 -2
- data/ext/nokogiri/xml_attribute_decl.c +3 -3
- data/ext/nokogiri/xml_cdata.c +1 -1
- data/ext/nokogiri/xml_document.c +36 -36
- data/ext/nokogiri/xml_document_fragment.c +0 -2
- data/ext/nokogiri/xml_dtd.c +10 -10
- data/ext/nokogiri/xml_element_decl.c +3 -3
- data/ext/nokogiri/xml_encoding_handler.c +25 -11
- data/ext/nokogiri/xml_entity_decl.c +5 -5
- data/ext/nokogiri/xml_node.c +707 -381
- data/ext/nokogiri/xml_node_set.c +4 -4
- data/ext/nokogiri/xml_reader.c +88 -11
- data/ext/nokogiri/xml_sax_parser_context.c +10 -3
- data/ext/nokogiri/xml_schema.c +3 -3
- data/ext/nokogiri/xml_text.c +1 -1
- data/ext/nokogiri/xml_xpath_context.c +73 -50
- data/ext/nokogiri/xslt_stylesheet.c +107 -9
- data/gumbo-parser/src/parser.c +0 -11
- data/lib/nokogiri/class_resolver.rb +67 -0
- data/lib/nokogiri/css/node.rb +9 -8
- data/lib/nokogiri/css/parser.rb +360 -341
- data/lib/nokogiri/css/parser.y +249 -244
- data/lib/nokogiri/css/parser_extras.rb +22 -20
- data/lib/nokogiri/css/syntax_error.rb +1 -0
- data/lib/nokogiri/css/tokenizer.rb +4 -3
- data/lib/nokogiri/css/tokenizer.rex +3 -2
- data/lib/nokogiri/css/xpath_visitor.rb +179 -82
- data/lib/nokogiri/css.rb +38 -6
- data/lib/nokogiri/decorators/slop.rb +8 -7
- data/lib/nokogiri/extension.rb +1 -1
- data/lib/nokogiri/gumbo.rb +1 -0
- data/lib/nokogiri/html.rb +16 -10
- data/lib/nokogiri/html4/builder.rb +1 -0
- data/lib/nokogiri/html4/document.rb +88 -77
- data/lib/nokogiri/html4/document_fragment.rb +11 -7
- data/lib/nokogiri/html4/element_description.rb +1 -0
- data/lib/nokogiri/html4/element_description_defaults.rb +426 -520
- data/lib/nokogiri/html4/entity_lookup.rb +2 -1
- data/lib/nokogiri/html4/sax/parser.rb +5 -2
- data/lib/nokogiri/html4/sax/parser_context.rb +1 -0
- data/lib/nokogiri/html4/sax/push_parser.rb +7 -7
- data/lib/nokogiri/html4.rb +11 -5
- data/lib/nokogiri/html5/document.rb +27 -10
- data/lib/nokogiri/html5/document_fragment.rb +5 -2
- data/lib/nokogiri/html5/node.rb +10 -3
- data/lib/nokogiri/html5.rb +69 -64
- data/lib/nokogiri/jruby/dependencies.rb +10 -9
- data/lib/nokogiri/syntax_error.rb +1 -0
- data/lib/nokogiri/version/constant.rb +2 -1
- data/lib/nokogiri/version/info.rb +20 -13
- data/lib/nokogiri/version.rb +1 -0
- data/lib/nokogiri/xml/attr.rb +5 -3
- data/lib/nokogiri/xml/attribute_decl.rb +2 -1
- data/lib/nokogiri/xml/builder.rb +34 -32
- data/lib/nokogiri/xml/cdata.rb +2 -1
- data/lib/nokogiri/xml/character_data.rb +1 -0
- data/lib/nokogiri/xml/document.rb +144 -103
- data/lib/nokogiri/xml/document_fragment.rb +41 -38
- data/lib/nokogiri/xml/dtd.rb +3 -2
- data/lib/nokogiri/xml/element_content.rb +1 -0
- data/lib/nokogiri/xml/element_decl.rb +2 -1
- data/lib/nokogiri/xml/entity_decl.rb +3 -2
- data/lib/nokogiri/xml/entity_reference.rb +1 -0
- data/lib/nokogiri/xml/namespace.rb +2 -0
- data/lib/nokogiri/xml/node/save_options.rb +8 -4
- data/lib/nokogiri/xml/node.rb +521 -351
- data/lib/nokogiri/xml/node_set.rb +50 -54
- data/lib/nokogiri/xml/notation.rb +12 -0
- data/lib/nokogiri/xml/parse_options.rb +12 -7
- data/lib/nokogiri/xml/pp/character_data.rb +8 -6
- data/lib/nokogiri/xml/pp/node.rb +24 -26
- data/lib/nokogiri/xml/pp.rb +1 -0
- data/lib/nokogiri/xml/processing_instruction.rb +2 -1
- data/lib/nokogiri/xml/reader.rb +20 -24
- data/lib/nokogiri/xml/relax_ng.rb +1 -0
- data/lib/nokogiri/xml/sax/document.rb +20 -19
- data/lib/nokogiri/xml/sax/parser.rb +37 -34
- data/lib/nokogiri/xml/sax/parser_context.rb +7 -3
- data/lib/nokogiri/xml/sax/push_parser.rb +5 -5
- data/lib/nokogiri/xml/sax.rb +1 -0
- data/lib/nokogiri/xml/schema.rb +7 -6
- data/lib/nokogiri/xml/searchable.rb +93 -62
- data/lib/nokogiri/xml/syntax_error.rb +5 -4
- data/lib/nokogiri/xml/text.rb +1 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +2 -1
- data/lib/nokogiri/xml/xpath.rb +12 -0
- data/lib/nokogiri/xml/xpath_context.rb +2 -3
- data/lib/nokogiri/xml.rb +4 -3
- data/lib/nokogiri/xslt/stylesheet.rb +1 -0
- data/lib/nokogiri/xslt.rb +21 -13
- data/lib/nokogiri.rb +19 -16
- data/lib/xsd/xmlparser/nokogiri.rb +25 -24
- data/patches/libxml2/0004-use-glibc-strlen.patch +3 -3
- data/patches/libxml2/0006-update-automake-files-for-arm64.patch +2443 -1914
- data/patches/libxml2/0008-htmlParseComment-handle-abruptly-closed-comments.patch +61 -0
- data/patches/libxml2/0009-allow-wildcard-namespaces.patch +77 -0
- data/patches/libxslt/0001-update-automake-files-for-arm64.patch +2445 -1919
- data/ports/archives/libxml2-2.9.14.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.35.tar.xz +0 -0
- metadata +104 -32
- data/patches/libxml2/0007-Fix-XPath-recursion-limit.patch +0 -31
- data/patches/libxslt/0002-Fix-xml2-config-check-in-configure-script.patch +0 -19
- data/ports/archives/libxml2-2.9.12.tar.gz +0 -0
- data/ports/archives/libxslt-1.1.34.tar.gz +0 -0
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "singleton"
|
3
4
|
require "shellwords"
|
4
5
|
|
@@ -102,8 +103,8 @@ module Nokogiri
|
|
102
103
|
ldflags = []
|
103
104
|
|
104
105
|
if libxml2_using_packaged?
|
105
|
-
cppflags << "-I#{File.join(header_directory,
|
106
|
-
cppflags << "-I#{File.join(header_directory,
|
106
|
+
cppflags << "-I#{File.join(header_directory, "include").shellescape}"
|
107
|
+
cppflags << "-I#{File.join(header_directory, "include/libxml2").shellescape}"
|
107
108
|
|
108
109
|
if windows?
|
109
110
|
# on windows, nokogumbo needs to link against nokogiri.so to resolve symbols. see #2167
|
@@ -176,13 +177,9 @@ module Nokogiri
|
|
176
177
|
end
|
177
178
|
|
178
179
|
def to_markdown
|
179
|
-
begin
|
180
|
-
require "psych"
|
181
|
-
rescue LoadError
|
182
|
-
end
|
183
180
|
require "yaml"
|
184
181
|
"# Nokogiri (#{Nokogiri::VERSION})\n" +
|
185
|
-
|
182
|
+
YAML.dump(to_hash).each_line.map { |line| " #{line}" }.join
|
186
183
|
end
|
187
184
|
|
188
185
|
instance.warnings.each do |warning|
|
@@ -190,26 +187,36 @@ module Nokogiri
|
|
190
187
|
end
|
191
188
|
end
|
192
189
|
|
193
|
-
|
190
|
+
# :nodoc:
|
191
|
+
def self.uses_libxml?(requirement = nil)
|
194
192
|
return false unless VersionInfo.instance.libxml2?
|
195
193
|
return true unless requirement
|
194
|
+
|
196
195
|
Gem::Requirement.new(requirement).satisfied_by?(VersionInfo.instance.loaded_libxml_version)
|
197
196
|
end
|
198
197
|
|
198
|
+
# :nodoc:
|
199
199
|
def self.uses_gumbo?
|
200
200
|
uses_libxml? # TODO: replace with Gumbo functionality
|
201
201
|
end
|
202
202
|
|
203
|
-
|
203
|
+
# :nodoc:
|
204
|
+
def self.jruby?
|
204
205
|
VersionInfo.instance.jruby?
|
205
206
|
end
|
206
207
|
|
207
|
-
#
|
208
|
-
|
209
|
-
|
208
|
+
# :nodoc:
|
209
|
+
def self.libxml2_patches
|
210
|
+
if VersionInfo.instance.libxml2_using_packaged?
|
211
|
+
Nokogiri::VERSION_INFO["libxml"]["patches"]
|
212
|
+
else
|
213
|
+
[]
|
214
|
+
end
|
210
215
|
end
|
216
|
+
|
217
|
+
require_relative "../jruby/dependencies" if Nokogiri.jruby?
|
211
218
|
require_relative "../extension"
|
212
219
|
|
213
|
-
#
|
220
|
+
# Detailed version info about Nokogiri and the installed extension dependencies.
|
214
221
|
VERSION_INFO = VersionInfo.instance.to_hash
|
215
222
|
end
|
data/lib/nokogiri/version.rb
CHANGED
data/lib/nokogiri/xml/attr.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Nokogiri
|
3
4
|
module XML
|
4
5
|
class Attr < Node
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
alias_method :value, :content
|
7
|
+
alias_method :to_s, :content
|
8
|
+
alias_method :content=, :value=
|
8
9
|
|
9
10
|
private
|
11
|
+
|
10
12
|
def inspect_attributes
|
11
13
|
[:name, :namespace, :value]
|
12
14
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Nokogiri
|
3
4
|
module XML
|
4
5
|
###
|
@@ -12,7 +13,7 @@ module Nokogiri
|
|
12
13
|
undef_method :line if method_defined?(:line)
|
13
14
|
|
14
15
|
def inspect
|
15
|
-
"#<#{self.class.name}:#{
|
16
|
+
"#<#{self.class.name}:#{format("0x%x", object_id)} #{to_s.inspect}>"
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
data/lib/nokogiri/xml/builder.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Nokogiri
|
3
4
|
module XML
|
4
5
|
###
|
@@ -261,7 +262,9 @@ module Nokogiri
|
|
261
262
|
# </root>
|
262
263
|
#
|
263
264
|
class Builder
|
264
|
-
|
265
|
+
include Nokogiri::ClassResolver
|
266
|
+
|
267
|
+
DEFAULT_DOCUMENT_OPTIONS = { namespace_inheritance: true }
|
265
268
|
|
266
269
|
# The current Document object being built
|
267
270
|
attr_accessor :doc
|
@@ -306,13 +309,7 @@ module Nokogiri
|
|
306
309
|
@doc = root.document
|
307
310
|
@parent = root
|
308
311
|
else
|
309
|
-
|
310
|
-
klass = begin
|
311
|
-
Object.const_get(klassname)
|
312
|
-
rescue NameError
|
313
|
-
Nokogiri::XML::Document
|
314
|
-
end
|
315
|
-
@parent = @doc = klass.new
|
312
|
+
@parent = @doc = related_class("Document").new
|
316
313
|
end
|
317
314
|
|
318
315
|
@context = nil
|
@@ -324,7 +321,7 @@ module Nokogiri
|
|
324
321
|
@doc.send(:"#{k}=", v)
|
325
322
|
end
|
326
323
|
|
327
|
-
return unless
|
324
|
+
return unless block
|
328
325
|
|
329
326
|
@arity = block.arity
|
330
327
|
if @arity <= 0
|
@@ -340,19 +337,19 @@ module Nokogiri
|
|
340
337
|
###
|
341
338
|
# Create a Text Node with content of +string+
|
342
339
|
def text(string)
|
343
|
-
insert
|
340
|
+
insert(@doc.create_text_node(string))
|
344
341
|
end
|
345
342
|
|
346
343
|
###
|
347
344
|
# Create a CDATA Node with content of +string+
|
348
345
|
def cdata(string)
|
349
|
-
insert
|
346
|
+
insert(doc.create_cdata(string))
|
350
347
|
end
|
351
348
|
|
352
349
|
###
|
353
350
|
# Create a Comment Node with content of +string+
|
354
351
|
def comment(string)
|
355
|
-
insert
|
352
|
+
insert(doc.create_comment(string))
|
356
353
|
end
|
357
354
|
|
358
355
|
###
|
@@ -366,12 +363,13 @@ module Nokogiri
|
|
366
363
|
|
367
364
|
@parent.ancestors.each do |a|
|
368
365
|
next if a == doc
|
366
|
+
|
369
367
|
@ns = a.namespace_definitions.find { |x| x.prefix == ns.to_s }
|
370
368
|
return self if @ns
|
371
369
|
end
|
372
370
|
|
373
|
-
@ns = { :
|
374
|
-
|
371
|
+
@ns = { pending: ns.to_s }
|
372
|
+
self
|
375
373
|
end
|
376
374
|
|
377
375
|
###
|
@@ -379,7 +377,7 @@ module Nokogiri
|
|
379
377
|
def to_xml(*args)
|
380
378
|
if Nokogiri.jruby?
|
381
379
|
options = args.first.is_a?(Hash) ? args.shift : {}
|
382
|
-
|
380
|
+
unless options[:save_with]
|
383
381
|
options[:save_with] = Node::SaveOptions::AS_BUILDER
|
384
382
|
end
|
385
383
|
args.insert(0, options)
|
@@ -394,22 +392,23 @@ module Nokogiri
|
|
394
392
|
end
|
395
393
|
|
396
394
|
def method_missing(method, *args, &block) # :nodoc:
|
397
|
-
if @context
|
395
|
+
if @context&.respond_to?(method)
|
398
396
|
@context.send(method, *args, &block)
|
399
397
|
else
|
400
|
-
node = @doc.create_element(method.to_s.sub(/[_!]$/, ""), *args)
|
398
|
+
node = @doc.create_element(method.to_s.sub(/[_!]$/, ""), *args) do |n|
|
401
399
|
# Set up the namespace
|
402
|
-
if @ns.is_a?
|
400
|
+
if @ns.is_a?(Nokogiri::XML::Namespace)
|
403
401
|
n.namespace = @ns
|
404
402
|
@ns = nil
|
405
403
|
end
|
406
|
-
|
404
|
+
end
|
407
405
|
|
408
|
-
if @ns.is_a?
|
406
|
+
if @ns.is_a?(Hash)
|
409
407
|
node.namespace = node.namespace_definitions.find { |x| x.prefix == @ns[:pending] }
|
410
408
|
if node.namespace.nil?
|
411
409
|
raise ArgumentError, "Namespace #{@ns[:pending]} has not been defined"
|
412
410
|
end
|
411
|
+
|
413
412
|
@ns = nil
|
414
413
|
end
|
415
414
|
|
@@ -423,16 +422,19 @@ module Nokogiri
|
|
423
422
|
# Insert +node+ as a child of the current Node
|
424
423
|
def insert(node, &block)
|
425
424
|
node = @parent.add_child(node)
|
426
|
-
if
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
425
|
+
if block
|
426
|
+
begin
|
427
|
+
old_parent = @parent
|
428
|
+
@parent = node
|
429
|
+
@arity ||= block.arity
|
430
|
+
if @arity <= 0
|
431
|
+
instance_eval(&block)
|
432
|
+
else
|
433
|
+
yield(self)
|
434
|
+
end
|
435
|
+
ensure
|
436
|
+
@parent = old_parent
|
434
437
|
end
|
435
|
-
@parent = old_parent
|
436
438
|
end
|
437
439
|
NodeBuilder.new(node, self)
|
438
440
|
end
|
@@ -455,10 +457,10 @@ module Nokogiri
|
|
455
457
|
opts = args.last.is_a?(Hash) ? args.pop : {}
|
456
458
|
case method.to_s
|
457
459
|
when /^(.*)!$/
|
458
|
-
@node["id"] =
|
460
|
+
@node["id"] = Regexp.last_match(1)
|
459
461
|
@node.content = args.first if args.first
|
460
462
|
when /^(.*)=/
|
461
|
-
@node[
|
463
|
+
@node[Regexp.last_match(1)] = args.first
|
462
464
|
else
|
463
465
|
@node["class"] =
|
464
466
|
((@node["class"] || "").split(/\s/) + [method.to_s]).join(" ")
|
@@ -470,7 +472,7 @@ module Nokogiri
|
|
470
472
|
@node[k.to_s] = ((@node[k.to_s] || "").split(/\s/) + [v]).join(" ")
|
471
473
|
end
|
472
474
|
|
473
|
-
if
|
475
|
+
if block
|
474
476
|
old_parent = @doc_builder.parent
|
475
477
|
@doc_builder.parent = @node
|
476
478
|
value = @doc_builder.instance_eval(&block)
|
data/lib/nokogiri/xml/cdata.rb
CHANGED