nokogiri 1.12.3-x64-mingw32 → 1.13.1-x64-mingw32

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.

Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -0
  3. data/README.md +9 -7
  4. data/bin/nokogiri +63 -50
  5. data/dependencies.yml +5 -6
  6. data/ext/nokogiri/extconf.rb +47 -35
  7. data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +1 -0
  8. data/ext/nokogiri/include/libxslt/xsltconfig.h +1 -1
  9. data/ext/nokogiri/xml_document.c +35 -35
  10. data/ext/nokogiri/xml_document_fragment.c +0 -2
  11. data/ext/nokogiri/xml_dtd.c +2 -2
  12. data/ext/nokogiri/xml_encoding_handler.c +25 -11
  13. data/ext/nokogiri/xml_node.c +645 -333
  14. data/ext/nokogiri/xml_reader.c +37 -11
  15. data/ext/nokogiri/xml_xpath_context.c +72 -49
  16. data/ext/nokogiri/xslt_stylesheet.c +107 -9
  17. data/lib/nokogiri/2.6/nokogiri.so +0 -0
  18. data/lib/nokogiri/2.7/nokogiri.so +0 -0
  19. data/lib/nokogiri/3.0/nokogiri.so +0 -0
  20. data/lib/nokogiri/class_resolver.rb +67 -0
  21. data/lib/nokogiri/css/node.rb +9 -8
  22. data/lib/nokogiri/css/parser.rb +360 -341
  23. data/lib/nokogiri/css/parser.y +249 -244
  24. data/lib/nokogiri/css/parser_extras.rb +20 -20
  25. data/lib/nokogiri/css/syntax_error.rb +1 -0
  26. data/lib/nokogiri/css/tokenizer.rb +4 -3
  27. data/lib/nokogiri/css/tokenizer.rex +3 -2
  28. data/lib/nokogiri/css/xpath_visitor.rb +179 -82
  29. data/lib/nokogiri/css.rb +38 -6
  30. data/lib/nokogiri/decorators/slop.rb +8 -7
  31. data/lib/nokogiri/extension.rb +1 -1
  32. data/lib/nokogiri/gumbo.rb +1 -0
  33. data/lib/nokogiri/html.rb +16 -10
  34. data/lib/nokogiri/html4/builder.rb +1 -0
  35. data/lib/nokogiri/html4/document.rb +84 -75
  36. data/lib/nokogiri/html4/document_fragment.rb +11 -7
  37. data/lib/nokogiri/html4/element_description.rb +1 -0
  38. data/lib/nokogiri/html4/element_description_defaults.rb +426 -520
  39. data/lib/nokogiri/html4/entity_lookup.rb +2 -1
  40. data/lib/nokogiri/html4/sax/parser.rb +2 -1
  41. data/lib/nokogiri/html4/sax/parser_context.rb +1 -0
  42. data/lib/nokogiri/html4/sax/push_parser.rb +7 -7
  43. data/lib/nokogiri/html4.rb +11 -5
  44. data/lib/nokogiri/html5/document.rb +24 -10
  45. data/lib/nokogiri/html5/document_fragment.rb +5 -2
  46. data/lib/nokogiri/html5/node.rb +6 -3
  47. data/lib/nokogiri/html5.rb +68 -64
  48. data/lib/nokogiri/jruby/dependencies.rb +10 -9
  49. data/lib/nokogiri/syntax_error.rb +1 -0
  50. data/lib/nokogiri/version/constant.rb +2 -1
  51. data/lib/nokogiri/version/info.rb +19 -13
  52. data/lib/nokogiri/version.rb +1 -0
  53. data/lib/nokogiri/xml/attr.rb +5 -3
  54. data/lib/nokogiri/xml/attribute_decl.rb +2 -1
  55. data/lib/nokogiri/xml/builder.rb +69 -31
  56. data/lib/nokogiri/xml/cdata.rb +2 -1
  57. data/lib/nokogiri/xml/character_data.rb +1 -0
  58. data/lib/nokogiri/xml/document.rb +178 -96
  59. data/lib/nokogiri/xml/document_fragment.rb +41 -38
  60. data/lib/nokogiri/xml/dtd.rb +3 -2
  61. data/lib/nokogiri/xml/element_content.rb +1 -0
  62. data/lib/nokogiri/xml/element_decl.rb +2 -1
  63. data/lib/nokogiri/xml/entity_decl.rb +3 -2
  64. data/lib/nokogiri/xml/entity_reference.rb +1 -0
  65. data/lib/nokogiri/xml/namespace.rb +2 -0
  66. data/lib/nokogiri/xml/node/save_options.rb +7 -4
  67. data/lib/nokogiri/xml/node.rb +512 -348
  68. data/lib/nokogiri/xml/node_set.rb +46 -54
  69. data/lib/nokogiri/xml/notation.rb +12 -0
  70. data/lib/nokogiri/xml/parse_options.rb +11 -7
  71. data/lib/nokogiri/xml/pp/character_data.rb +8 -6
  72. data/lib/nokogiri/xml/pp/node.rb +24 -26
  73. data/lib/nokogiri/xml/pp.rb +1 -0
  74. data/lib/nokogiri/xml/processing_instruction.rb +2 -1
  75. data/lib/nokogiri/xml/reader.rb +17 -19
  76. data/lib/nokogiri/xml/relax_ng.rb +1 -0
  77. data/lib/nokogiri/xml/sax/document.rb +20 -19
  78. data/lib/nokogiri/xml/sax/parser.rb +36 -34
  79. data/lib/nokogiri/xml/sax/parser_context.rb +7 -3
  80. data/lib/nokogiri/xml/sax/push_parser.rb +5 -5
  81. data/lib/nokogiri/xml/sax.rb +1 -0
  82. data/lib/nokogiri/xml/schema.rb +7 -6
  83. data/lib/nokogiri/xml/searchable.rb +93 -62
  84. data/lib/nokogiri/xml/syntax_error.rb +4 -4
  85. data/lib/nokogiri/xml/text.rb +1 -0
  86. data/lib/nokogiri/xml/xpath/syntax_error.rb +2 -1
  87. data/lib/nokogiri/xml/xpath.rb +12 -0
  88. data/lib/nokogiri/xml/xpath_context.rb +2 -3
  89. data/lib/nokogiri/xml.rb +3 -3
  90. data/lib/nokogiri/xslt/stylesheet.rb +1 -0
  91. data/lib/nokogiri/xslt.rb +21 -13
  92. data/lib/nokogiri.rb +19 -16
  93. data/lib/xsd/xmlparser/nokogiri.rb +25 -24
  94. metadata +122 -51
  95. data/lib/nokogiri/2.5/nokogiri.so +0 -0
@@ -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
- alias :value :content
6
- alias :to_s :content
7
- alias :content= :value=
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}:#{sprintf("0x%x", object_id)} #{to_s.inspect}>"
16
+ "#<#{self.class.name}:#{format("0x%x", object_id)} #{to_s.inspect}>"
16
17
  end
17
18
  end
18
19
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Nokogiri
3
4
  module XML
4
5
  ###
@@ -196,6 +197,41 @@ module Nokogiri
196
197
  #
197
198
  # Note the "foo:object" tag.
198
199
  #
200
+ # === Namespace inheritance
201
+ #
202
+ # In the Builder context, children will inherit their parent's namespace. This is the same
203
+ # behavior as if the underlying {XML::Document} set +namespace_inheritance+ to +true+:
204
+ #
205
+ # result = Nokogiri::XML::Builder.new do |xml|
206
+ # xml["soapenv"].Envelope("xmlns:soapenv" => "http://schemas.xmlsoap.org/soap/envelope/") do
207
+ # xml.Header
208
+ # end
209
+ # end
210
+ # result.doc.to_xml
211
+ # # => <?xml version="1.0" encoding="utf-8"?>
212
+ # # <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
213
+ # # <soapenv:Header/>
214
+ # # </soapenv:Envelope>
215
+ #
216
+ # Users may turn this behavior off by passing a keyword argument +namespace_inheritance:false+
217
+ # to the initializer:
218
+ #
219
+ # result = Nokogiri::XML::Builder.new(namespace_inheritance: false) do |xml|
220
+ # xml["soapenv"].Envelope("xmlns:soapenv" => "http://schemas.xmlsoap.org/soap/envelope/") do
221
+ # xml.Header
222
+ # xml["soapenv"].Body # users may explicitly opt into the namespace
223
+ # end
224
+ # end
225
+ # result.doc.to_xml
226
+ # # => <?xml version="1.0" encoding="utf-8"?>
227
+ # # <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
228
+ # # <Header/>
229
+ # # <soapenv:Body/>
230
+ # # </soapenv:Envelope>
231
+ #
232
+ # For more information on namespace inheritance, please see {XML::Document#namespace_inheritance}
233
+ #
234
+ #
199
235
  # == Document Types
200
236
  #
201
237
  # To create a document type (DTD), access use the Builder#doc method to get
@@ -226,6 +262,10 @@ module Nokogiri
226
262
  # </root>
227
263
  #
228
264
  class Builder
265
+ include Nokogiri::ClassResolver
266
+
267
+ DEFAULT_DOCUMENT_OPTIONS = { namespace_inheritance: true }
268
+
229
269
  # The current Document object being built
230
270
  attr_accessor :doc
231
271
 
@@ -269,24 +309,19 @@ module Nokogiri
269
309
  @doc = root.document
270
310
  @parent = root
271
311
  else
272
- klassname = "::" + (self.class.name.split("::")[0..-2] + ["Document"]).join("::")
273
- klass = begin
274
- Object.const_get(klassname)
275
- rescue NameError
276
- Nokogiri::XML::Document
277
- end
278
- @parent = @doc = klass.new
312
+ @parent = @doc = related_class("Document").new
279
313
  end
280
314
 
281
315
  @context = nil
282
316
  @arity = nil
283
317
  @ns = nil
284
318
 
319
+ options = DEFAULT_DOCUMENT_OPTIONS.merge(options)
285
320
  options.each do |k, v|
286
321
  @doc.send(:"#{k}=", v)
287
322
  end
288
323
 
289
- return unless block_given?
324
+ return unless block
290
325
 
291
326
  @arity = block.arity
292
327
  if @arity <= 0
@@ -302,19 +337,19 @@ module Nokogiri
302
337
  ###
303
338
  # Create a Text Node with content of +string+
304
339
  def text(string)
305
- insert @doc.create_text_node(string)
340
+ insert(@doc.create_text_node(string))
306
341
  end
307
342
 
308
343
  ###
309
344
  # Create a CDATA Node with content of +string+
310
345
  def cdata(string)
311
- insert doc.create_cdata(string)
346
+ insert(doc.create_cdata(string))
312
347
  end
313
348
 
314
349
  ###
315
350
  # Create a Comment Node with content of +string+
316
351
  def comment(string)
317
- insert doc.create_comment(string)
352
+ insert(doc.create_comment(string))
318
353
  end
319
354
 
320
355
  ###
@@ -332,8 +367,8 @@ module Nokogiri
332
367
  return self if @ns
333
368
  end
334
369
 
335
- @ns = { :pending => ns.to_s }
336
- return self
370
+ @ns = { pending: ns.to_s }
371
+ self
337
372
  end
338
373
 
339
374
  ###
@@ -341,7 +376,7 @@ module Nokogiri
341
376
  def to_xml(*args)
342
377
  if Nokogiri.jruby?
343
378
  options = args.first.is_a?(Hash) ? args.shift : {}
344
- if !options[:save_with]
379
+ unless options[:save_with]
345
380
  options[:save_with] = Node::SaveOptions::AS_BUILDER
346
381
  end
347
382
  args.insert(0, options)
@@ -356,18 +391,18 @@ module Nokogiri
356
391
  end
357
392
 
358
393
  def method_missing(method, *args, &block) # :nodoc:
359
- if @context && @context.respond_to?(method)
394
+ if @context&.respond_to?(method)
360
395
  @context.send(method, *args, &block)
361
396
  else
362
- node = @doc.create_element(method.to_s.sub(/[_!]$/, ""), *args) { |n|
397
+ node = @doc.create_element(method.to_s.sub(/[_!]$/, ""), *args) do |n|
363
398
  # Set up the namespace
364
- if @ns.is_a? Nokogiri::XML::Namespace
399
+ if @ns.is_a?(Nokogiri::XML::Namespace)
365
400
  n.namespace = @ns
366
401
  @ns = nil
367
402
  end
368
- }
403
+ end
369
404
 
370
- if @ns.is_a? Hash
405
+ if @ns.is_a?(Hash)
371
406
  node.namespace = node.namespace_definitions.find { |x| x.prefix == @ns[:pending] }
372
407
  if node.namespace.nil?
373
408
  raise ArgumentError, "Namespace #{@ns[:pending]} has not been defined"
@@ -385,16 +420,19 @@ module Nokogiri
385
420
  # Insert +node+ as a child of the current Node
386
421
  def insert(node, &block)
387
422
  node = @parent.add_child(node)
388
- if block_given?
389
- old_parent = @parent
390
- @parent = node
391
- @arity ||= block.arity
392
- if @arity <= 0
393
- instance_eval(&block)
394
- else
395
- block.call(self)
423
+ if block
424
+ begin
425
+ old_parent = @parent
426
+ @parent = node
427
+ @arity ||= block.arity
428
+ if @arity <= 0
429
+ instance_eval(&block)
430
+ else
431
+ yield(self)
432
+ end
433
+ ensure
434
+ @parent = old_parent
396
435
  end
397
- @parent = old_parent
398
436
  end
399
437
  NodeBuilder.new(node, self)
400
438
  end
@@ -417,10 +455,10 @@ module Nokogiri
417
455
  opts = args.last.is_a?(Hash) ? args.pop : {}
418
456
  case method.to_s
419
457
  when /^(.*)!$/
420
- @node["id"] = $1
458
+ @node["id"] = Regexp.last_match(1)
421
459
  @node.content = args.first if args.first
422
460
  when /^(.*)=/
423
- @node[$1] = args.first
461
+ @node[Regexp.last_match(1)] = args.first
424
462
  else
425
463
  @node["class"] =
426
464
  ((@node["class"] || "").split(/\s/) + [method.to_s]).join(" ")
@@ -432,7 +470,7 @@ module Nokogiri
432
470
  @node[k.to_s] = ((@node[k.to_s] || "").split(/\s/) + [v]).join(" ")
433
471
  end
434
472
 
435
- if block_given?
473
+ if block
436
474
  old_parent = @doc_builder.parent
437
475
  @doc_builder.parent = @node
438
476
  value = @doc_builder.instance_eval(&block)
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Nokogiri
3
4
  module XML
4
5
  class CDATA < Nokogiri::XML::Text
5
6
  ###
6
7
  # Get the name of this CDATA node
7
8
  def name
8
- '#cdata-section'
9
+ "#cdata-section"
9
10
  end
10
11
  end
11
12
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Nokogiri
3
4
  module XML
4
5
  class CharacterData < Nokogiri::XML::Node