nokogiri 1.12.3-x86_64-darwin → 1.13.1-x86_64-darwin
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 +5 -0
- data/README.md +9 -7
- data/bin/nokogiri +63 -50
- data/dependencies.yml +5 -6
- data/ext/nokogiri/extconf.rb +47 -35
- data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +1 -0
- data/ext/nokogiri/include/libxslt/xsltconfig.h +1 -1
- data/ext/nokogiri/xml_document.c +35 -35
- data/ext/nokogiri/xml_document_fragment.c +0 -2
- data/ext/nokogiri/xml_dtd.c +2 -2
- data/ext/nokogiri/xml_encoding_handler.c +25 -11
- data/ext/nokogiri/xml_node.c +645 -333
- data/ext/nokogiri/xml_reader.c +37 -11
- data/ext/nokogiri/xml_xpath_context.c +72 -49
- data/ext/nokogiri/xslt_stylesheet.c +107 -9
- data/lib/nokogiri/2.6/nokogiri.bundle +0 -0
- data/lib/nokogiri/2.7/nokogiri.bundle +0 -0
- data/lib/nokogiri/3.0/nokogiri.bundle +0 -0
- data/lib/nokogiri/{2.5 → 3.1}/nokogiri.bundle +0 -0
- 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 +20 -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 +84 -75
- 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 +2 -1
- 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 +24 -10
- data/lib/nokogiri/html5/document_fragment.rb +5 -2
- data/lib/nokogiri/html5/node.rb +6 -3
- data/lib/nokogiri/html5.rb +68 -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 +19 -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 +69 -31
- data/lib/nokogiri/xml/cdata.rb +2 -1
- data/lib/nokogiri/xml/character_data.rb +1 -0
- data/lib/nokogiri/xml/document.rb +178 -96
- 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 +7 -4
- data/lib/nokogiri/xml/node.rb +512 -348
- data/lib/nokogiri/xml/node_set.rb +46 -54
- data/lib/nokogiri/xml/notation.rb +12 -0
- data/lib/nokogiri/xml/parse_options.rb +11 -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 +17 -19
- 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 +36 -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 +4 -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 +3 -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
- metadata +124 -52
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
|
###
|
@@ -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
|
-
|
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
|
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
|
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
|
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
|
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 = { :
|
336
|
-
|
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
|
-
|
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
|
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)
|
397
|
+
node = @doc.create_element(method.to_s.sub(/[_!]$/, ""), *args) do |n|
|
363
398
|
# Set up the namespace
|
364
|
-
if @ns.is_a?
|
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?
|
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
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
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"] =
|
458
|
+
@node["id"] = Regexp.last_match(1)
|
421
459
|
@node.content = args.first if args.first
|
422
460
|
when /^(.*)=/
|
423
|
-
@node[
|
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
|
473
|
+
if block
|
436
474
|
old_parent = @doc_builder.parent
|
437
475
|
@doc_builder.parent = @node
|
438
476
|
value = @doc_builder.instance_eval(&block)
|
data/lib/nokogiri/xml/cdata.rb
CHANGED