nokogiri 1.11.0.rc4 → 1.11.4
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 +3 -0
- data/LICENSE-DEPENDENCIES.md +12 -12
- data/LICENSE.md +1 -1
- data/README.md +168 -91
- data/dependencies.yml +12 -12
- data/ext/nokogiri/depend +34 -474
- data/ext/nokogiri/extconf.rb +270 -183
- data/ext/nokogiri/html_document.c +10 -15
- data/ext/nokogiri/html_element_description.c +84 -71
- data/ext/nokogiri/html_entity_lookup.c +21 -16
- data/ext/nokogiri/html_sax_parser_context.c +67 -64
- data/ext/nokogiri/html_sax_push_parser.c +42 -34
- data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
- data/ext/nokogiri/nokogiri.c +171 -60
- data/ext/nokogiri/nokogiri.h +158 -75
- data/ext/nokogiri/test_global_handlers.c +40 -0
- data/ext/nokogiri/xml_attr.c +15 -15
- data/ext/nokogiri/xml_attribute_decl.c +18 -18
- data/ext/nokogiri/xml_cdata.c +13 -18
- data/ext/nokogiri/xml_comment.c +19 -26
- data/ext/nokogiri/xml_document.c +246 -188
- data/ext/nokogiri/xml_document_fragment.c +13 -15
- data/ext/nokogiri/xml_dtd.c +54 -48
- data/ext/nokogiri/xml_element_content.c +30 -27
- data/ext/nokogiri/xml_element_decl.c +22 -22
- data/ext/nokogiri/xml_encoding_handler.c +17 -11
- data/ext/nokogiri/xml_entity_decl.c +32 -30
- data/ext/nokogiri/xml_entity_reference.c +16 -18
- data/ext/nokogiri/xml_namespace.c +56 -49
- data/ext/nokogiri/xml_node.c +371 -320
- data/ext/nokogiri/xml_node_set.c +168 -156
- data/ext/nokogiri/xml_processing_instruction.c +17 -19
- data/ext/nokogiri/xml_reader.c +191 -157
- data/ext/nokogiri/xml_relax_ng.c +29 -23
- data/ext/nokogiri/xml_sax_parser.c +117 -112
- data/ext/nokogiri/xml_sax_parser_context.c +101 -84
- data/ext/nokogiri/xml_sax_push_parser.c +36 -27
- data/ext/nokogiri/xml_schema.c +48 -42
- data/ext/nokogiri/xml_syntax_error.c +42 -21
- data/ext/nokogiri/xml_text.c +13 -17
- data/ext/nokogiri/xml_xpath_context.c +134 -127
- data/ext/nokogiri/xslt_stylesheet.c +157 -157
- data/lib/nokogiri.rb +2 -6
- data/lib/nokogiri/css/parser.rb +1 -1
- data/lib/nokogiri/extension.rb +26 -0
- data/lib/nokogiri/html/document_fragment.rb +15 -15
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/version/info.rb +31 -8
- data/lib/nokogiri/xml/document.rb +74 -28
- data/lib/nokogiri/xml/node.rb +39 -42
- data/lib/nokogiri/xml/reader.rb +2 -9
- data/lib/nokogiri/xml/xpath.rb +1 -3
- data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
- data/patches/libxml2/{0002-Remove-script-macro-support.patch → 0001-Remove-script-macro-support.patch} +0 -0
- data/patches/libxml2/{0003-Update-entities-to-remove-handling-of-ssi.patch → 0002-Update-entities-to-remove-handling-of-ssi.patch} +0 -0
- data/patches/libxml2/{0004-libxml2.la-is-in-top_builddir.patch → 0003-libxml2.la-is-in-top_builddir.patch} +1 -1
- data/patches/libxml2/{0008-use-glibc-strlen.patch → 0004-use-glibc-strlen.patch} +0 -0
- data/patches/libxml2/0005-avoid-isnan-isinf.patch +81 -0
- data/patches/libxml2/0006-update-automake-files-for-arm64.patch +2511 -0
- data/patches/libxslt/0001-update-automake-files-for-arm64.patch +2511 -0
- data/patches/libxslt/0002-Fix-xml2-config-check-in-configure-script.patch +19 -0
- data/ports/archives/libxml2-2.9.12.tar.gz +0 -0
- metadata +71 -169
- data/ext/nokogiri/html_document.h +0 -10
- data/ext/nokogiri/html_element_description.h +0 -10
- data/ext/nokogiri/html_entity_lookup.h +0 -8
- data/ext/nokogiri/html_sax_parser_context.h +0 -11
- data/ext/nokogiri/html_sax_push_parser.h +0 -9
- data/ext/nokogiri/xml_attr.h +0 -9
- data/ext/nokogiri/xml_attribute_decl.h +0 -9
- data/ext/nokogiri/xml_cdata.h +0 -9
- data/ext/nokogiri/xml_comment.h +0 -9
- data/ext/nokogiri/xml_document.h +0 -23
- data/ext/nokogiri/xml_document_fragment.h +0 -10
- data/ext/nokogiri/xml_dtd.h +0 -10
- data/ext/nokogiri/xml_element_content.h +0 -10
- data/ext/nokogiri/xml_element_decl.h +0 -9
- data/ext/nokogiri/xml_encoding_handler.h +0 -8
- data/ext/nokogiri/xml_entity_decl.h +0 -10
- data/ext/nokogiri/xml_entity_reference.h +0 -9
- data/ext/nokogiri/xml_io.c +0 -63
- data/ext/nokogiri/xml_io.h +0 -11
- data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
- data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
- data/ext/nokogiri/xml_namespace.h +0 -14
- data/ext/nokogiri/xml_node.h +0 -13
- data/ext/nokogiri/xml_node_set.h +0 -12
- data/ext/nokogiri/xml_processing_instruction.h +0 -9
- data/ext/nokogiri/xml_reader.h +0 -10
- data/ext/nokogiri/xml_relax_ng.h +0 -9
- data/ext/nokogiri/xml_sax_parser.h +0 -39
- data/ext/nokogiri/xml_sax_parser_context.h +0 -10
- data/ext/nokogiri/xml_sax_push_parser.h +0 -9
- data/ext/nokogiri/xml_schema.h +0 -9
- data/ext/nokogiri/xml_syntax_error.h +0 -13
- data/ext/nokogiri/xml_text.h +0 -9
- data/ext/nokogiri/xml_xpath_context.h +0 -10
- data/ext/nokogiri/xslt_stylesheet.h +0 -14
- data/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch +0 -78
- data/patches/libxml2/0005-Fix-infinite-loop-in-xmlStringLenDecodeEntities.patch +0 -32
- data/patches/libxml2/0006-htmlParseComment-treat-as-if-it-closed-the-comment.patch +0 -73
- data/patches/libxml2/0007-use-new-htmlParseLookupCommentEnd-to-find-comment-en.patch +0 -103
- data/ports/archives/libxml2-2.9.10.tar.gz +0 -0
@@ -10,6 +10,14 @@ module Nokogiri
|
|
10
10
|
::JRUBY_VERSION if ::RUBY_PLATFORM == "java"
|
11
11
|
end
|
12
12
|
|
13
|
+
def windows?
|
14
|
+
::RUBY_PLATFORM =~ /mingw|mswin/
|
15
|
+
end
|
16
|
+
|
17
|
+
def ruby_minor
|
18
|
+
Gem::Version.new(::RUBY_VERSION).segments[0..1].join(".")
|
19
|
+
end
|
20
|
+
|
13
21
|
def engine
|
14
22
|
defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "mri"
|
15
23
|
end
|
@@ -74,18 +82,38 @@ module Nokogiri
|
|
74
82
|
|
75
83
|
def to_hash
|
76
84
|
header_directory = File.expand_path(File.join(File.dirname(__FILE__), "../../../ext/nokogiri"))
|
85
|
+
|
77
86
|
{}.tap do |vi|
|
78
87
|
vi["warnings"] = []
|
79
88
|
vi["nokogiri"] = {}.tap do |nokogiri|
|
80
89
|
nokogiri["version"] = Nokogiri::VERSION
|
81
90
|
|
82
91
|
unless jruby?
|
92
|
+
# enable gems like nokogumbo to build with the following in their extconf.rb:
|
93
|
+
#
|
94
|
+
# append_cflags(Nokogiri::VERSION_INFO["nokogiri"]["cppflags"])
|
95
|
+
# append_ldflags(Nokogiri::VERSION_INFO["nokogiri"]["ldflags"])
|
96
|
+
#
|
83
97
|
cppflags = ["-I#{header_directory.shellescape}"]
|
98
|
+
ldflags = []
|
99
|
+
|
84
100
|
if libxml2_using_packaged?
|
85
|
-
cppflags << "-I#{File.join(header_directory,
|
86
|
-
cppflags << "-I#{File.join(header_directory,
|
101
|
+
cppflags << "-I#{File.join(header_directory, 'include').shellescape}"
|
102
|
+
cppflags << "-I#{File.join(header_directory, 'include/libxml2').shellescape}"
|
103
|
+
|
104
|
+
if windows?
|
105
|
+
# on windows, nokogumbo needs to link against nokogiri.so to resolve symbols. see #2167
|
106
|
+
lib_directory = File.expand_path(File.join(File.dirname(__FILE__), "../#{ruby_minor}"))
|
107
|
+
unless File.exist?(lib_directory)
|
108
|
+
lib_directory = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
109
|
+
end
|
110
|
+
ldflags << "-L#{lib_directory.shellescape}"
|
111
|
+
ldflags << "-l:nokogiri.so"
|
112
|
+
end
|
87
113
|
end
|
114
|
+
|
88
115
|
nokogiri["cppflags"] = cppflags
|
116
|
+
nokogiri["ldflags"] = ldflags
|
89
117
|
end
|
90
118
|
end
|
91
119
|
vi["ruby"] = {}.tap do |ruby|
|
@@ -170,12 +198,7 @@ module Nokogiri
|
|
170
198
|
if Nokogiri.jruby?
|
171
199
|
require "nokogiri/jruby/dependencies"
|
172
200
|
end
|
173
|
-
|
174
|
-
::RUBY_VERSION =~ /(\d+\.\d+)/
|
175
|
-
require "nokogiri/#{Regexp.last_match(1)}/nokogiri"
|
176
|
-
rescue LoadError
|
177
|
-
require "nokogiri/nokogiri"
|
178
|
-
end
|
201
|
+
require "nokogiri/extension"
|
179
202
|
|
180
203
|
# More complete version information about libxml
|
181
204
|
VERSION_INFO = VersionInfo.instance.to_hash
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'pathname'
|
@@ -13,11 +14,12 @@ module Nokogiri
|
|
13
14
|
# Nokogiri::XML::Searchable#xpath
|
14
15
|
#
|
15
16
|
class Document < Nokogiri::XML::Node
|
16
|
-
#
|
17
|
-
#
|
17
|
+
# See http://www.w3.org/TR/REC-xml-names/#ns-decl for more details. Note that we're not
|
18
|
+
# attempting to handle unicode characters partly because libxml2 doesn't handle unicode
|
19
|
+
# characters in NCNAMEs.
|
18
20
|
NCNAME_START_CHAR = "A-Za-z_"
|
19
|
-
NCNAME_CHAR = NCNAME_START_CHAR + "
|
20
|
-
NCNAME_RE = /^xmlns(
|
21
|
+
NCNAME_CHAR = NCNAME_START_CHAR + "\\-\\.0-9"
|
22
|
+
NCNAME_RE = /^xmlns(?::([#{NCNAME_START_CHAR}][#{NCNAME_CHAR}]*))?$/
|
21
23
|
|
22
24
|
##
|
23
25
|
# Parse an XML file.
|
@@ -79,6 +81,35 @@ module Nokogiri
|
|
79
81
|
return doc
|
80
82
|
end
|
81
83
|
|
84
|
+
##
|
85
|
+
# @!method wrap(java_document)
|
86
|
+
# @!scope class
|
87
|
+
#
|
88
|
+
# Create a {Document} using an existing Java DOM document object.
|
89
|
+
#
|
90
|
+
# The returned {Document} shares the same underlying data structure as the Java object, so
|
91
|
+
# changes in one are reflected in the other.
|
92
|
+
#
|
93
|
+
# @param java_document [Java::OrgW3cDom::Document]
|
94
|
+
# @return [Nokogiri::XML::Document]
|
95
|
+
# @note This method is only available when running JRuby.
|
96
|
+
# @note The class +Java::OrgW3cDom::Document+ is also accessible as +org.w3c.dom.Document+.
|
97
|
+
# @see #to_java
|
98
|
+
|
99
|
+
##
|
100
|
+
# @!method to_java()
|
101
|
+
#
|
102
|
+
# Returns the underlying Java DOM document object for the {Document}.
|
103
|
+
#
|
104
|
+
# The returned Java object shares the same underlying data structure as the {Document}, so
|
105
|
+
# changes in one are reflected in the other.
|
106
|
+
#
|
107
|
+
# @return [Java::OrgW3cDom::Document]
|
108
|
+
# @note This method is only available when running JRuby.
|
109
|
+
# @note The class +Java::OrgW3cDom::Document+ is also accessible as +org.w3c.dom.Document+.
|
110
|
+
# @see .wrap
|
111
|
+
|
112
|
+
|
82
113
|
# A list of Nokogiri::XML::SyntaxError found when parsing a document
|
83
114
|
attr_accessor :errors
|
84
115
|
|
@@ -88,33 +119,58 @@ module Nokogiri
|
|
88
119
|
end
|
89
120
|
|
90
121
|
##
|
91
|
-
# Create
|
122
|
+
# Create a new +Element+ with +name+ sharing GC lifecycle with the document, optionally
|
123
|
+
# setting contents or attributes.
|
124
|
+
#
|
125
|
+
# Arguments may be passed to initialize the element:
|
126
|
+
# - a +Hash+ argument will be used to set attributes
|
127
|
+
# - a non-Hash object that responds to +#to_s+ will be used to set the new node's contents
|
92
128
|
#
|
93
|
-
#
|
94
|
-
# doc.create_element "div", :class => "container" # <div class='container'></div>
|
95
|
-
# doc.create_element "div", "contents" # <div>contents</div>
|
96
|
-
# doc.create_element "div", "contents", :class => "container" # <div class='container'>contents</div>
|
97
|
-
# doc.create_element "div" { |node| node['class'] = "container" } # <div class='container'></div>
|
129
|
+
# A block may be passed to mutate the node.
|
98
130
|
#
|
99
|
-
|
131
|
+
# @param name [String]
|
132
|
+
# @param contents_or_attrs [#to_s,Hash]
|
133
|
+
# @yieldparam node [Nokogiri::XML::Element]
|
134
|
+
# @return [Nokogiri::XML::Element]
|
135
|
+
#
|
136
|
+
# @example An empty element without attributes
|
137
|
+
# doc.create_element("div")
|
138
|
+
# # => <div></div>
|
139
|
+
#
|
140
|
+
# @example An element with contents
|
141
|
+
# doc.create_element("div", "contents")
|
142
|
+
# # => <div>contents</div>
|
143
|
+
#
|
144
|
+
# @example An element with attributes
|
145
|
+
# doc.create_element("div", {"class" => "container"})
|
146
|
+
# # => <div class='container'></div>
|
147
|
+
#
|
148
|
+
# @example An element with contents and attributes
|
149
|
+
# doc.create_element("div", "contents", {"class" => "container"})
|
150
|
+
# # => <div class='container'>contents</div>
|
151
|
+
#
|
152
|
+
# @example Passing a block to mutate the element
|
153
|
+
# doc.create_element("div") { |node| node["class"] = "blue" if before_noon? }
|
154
|
+
#
|
155
|
+
def create_element(name, *contents_or_attrs, &block)
|
100
156
|
elm = Nokogiri::XML::Element.new(name, self, &block)
|
101
|
-
|
157
|
+
contents_or_attrs.each do |arg|
|
102
158
|
case arg
|
103
159
|
when Hash
|
104
|
-
arg.each
|
160
|
+
arg.each do |k, v|
|
105
161
|
key = k.to_s
|
106
162
|
if key =~ NCNAME_RE
|
107
|
-
ns_name =
|
108
|
-
elm.add_namespace_definition
|
163
|
+
ns_name = Regexp.last_match(1)
|
164
|
+
elm.add_namespace_definition(ns_name, v)
|
109
165
|
else
|
110
166
|
elm[k.to_s] = v.to_s
|
111
167
|
end
|
112
|
-
|
168
|
+
end
|
113
169
|
else
|
114
170
|
elm.content = arg
|
115
171
|
end
|
116
172
|
end
|
117
|
-
if ns = elm.namespace_definitions.find { |n| n.prefix.nil?
|
173
|
+
if ns = elm.namespace_definitions.find { |n| n.prefix.nil? || (n.prefix == '') }
|
118
174
|
elm.namespace = ns
|
119
175
|
end
|
120
176
|
elm
|
@@ -262,24 +318,14 @@ module Nokogiri
|
|
262
318
|
end
|
263
319
|
alias :<< :add_child
|
264
320
|
|
265
|
-
##
|
266
|
-
# +JRuby+
|
267
|
-
# Wraps Java's org.w3c.dom.document and returns Nokogiri::XML::Document
|
268
|
-
def self.wrap(document) end if false # native-ext provides Document.wrap
|
269
|
-
|
270
|
-
##
|
271
|
-
# +JRuby+
|
272
|
-
# Returns Java's org.w3c.dom.document of this Document.
|
273
|
-
def to_java; end if false # JRuby provides #to_java
|
274
|
-
|
275
321
|
private
|
322
|
+
|
276
323
|
def self.empty_doc? string_or_io
|
277
324
|
string_or_io.nil? ||
|
278
325
|
(string_or_io.respond_to?(:empty?) && string_or_io.empty?) ||
|
279
326
|
(string_or_io.respond_to?(:eof?) && string_or_io.eof?)
|
280
327
|
end
|
281
328
|
|
282
|
-
# @private
|
283
329
|
IMPLIED_XPATH_CONTEXTS = [ '//'.freeze ].freeze # :nodoc:
|
284
330
|
|
285
331
|
def inspect_attributes
|
data/lib/nokogiri/xml/node.rb
CHANGED
@@ -5,64 +5,54 @@ require "nokogiri/xml/node/save_options"
|
|
5
5
|
|
6
6
|
module Nokogiri
|
7
7
|
module XML
|
8
|
-
|
9
|
-
# Nokogiri::XML::Node is your window to the fun filled world of dealing
|
10
|
-
#
|
11
|
-
#
|
8
|
+
##
|
9
|
+
# {Nokogiri::XML::Node} is your window to the fun filled world of dealing with XML and HTML
|
10
|
+
# tags. A {Nokogiri::XML::Node} may be treated similarly to a hash with regard to attributes. For
|
11
|
+
# example:
|
12
12
|
#
|
13
|
-
#
|
14
|
-
# => <a href
|
15
|
-
#
|
16
|
-
# => "
|
17
|
-
#
|
18
|
-
# =>
|
19
|
-
#
|
20
|
-
# => ["#foo", "link"]
|
21
|
-
# irb(main):008:0> node['class'] = 'green'
|
22
|
-
# => "green"
|
23
|
-
# irb(main):009:0> node
|
24
|
-
# => <a href="#foo" id="link" class="green">link</a>
|
25
|
-
# irb(main):010:0>
|
13
|
+
# node = Nokogiri::XML::DocumentFragment.parse("<a href='#foo' id='link'>link</a>").at_css("a")
|
14
|
+
# node.to_html # => "<a href=\"#foo\" id=\"link\">link</a>"
|
15
|
+
# node['href'] # => "#foo"
|
16
|
+
# node.keys # => ["href", "id"]
|
17
|
+
# node.values # => ["#foo", "link"]
|
18
|
+
# node['class'] = 'green' # => "green"
|
19
|
+
# node.to_html # => "<a href=\"#foo\" id=\"link\" class=\"green\">link</a>"
|
26
20
|
#
|
27
|
-
# See
|
21
|
+
# See the method group entitled "Working With Node Attributes" for the full set of methods.
|
28
22
|
#
|
29
|
-
# Nokogiri::XML::Node also has methods that let you move around your
|
23
|
+
# {Nokogiri::XML::Node} also has methods that let you move around your
|
30
24
|
# tree. For navigating your tree, see:
|
31
25
|
#
|
32
|
-
# *
|
33
|
-
# *
|
34
|
-
# *
|
35
|
-
# *
|
36
|
-
#
|
26
|
+
# * {#parent}
|
27
|
+
# * {#children}
|
28
|
+
# * {#next}
|
29
|
+
# * {#previous}
|
37
30
|
#
|
38
31
|
# When printing or otherwise emitting a document or a node (and
|
39
32
|
# its subtree), there are a few methods you might want to use:
|
40
33
|
#
|
41
|
-
# * content, text, inner_text, to_str: emit plaintext
|
42
|
-
#
|
43
|
-
#
|
44
|
-
# document, meaning that entities will be replaced (e.g., "<"
|
45
|
-
# will be replaced with "<"), meaning that any sanitizing will
|
46
|
-
# likely be un-done in the output.
|
34
|
+
# * {#content}, {#text}, {#inner_text}, {#to_str}: These methods will all <b>emit plaintext</b>,
|
35
|
+
# meaning that entities will be replaced (e.g., "<" will be replaced with "<"), meaning
|
36
|
+
# that any sanitizing will likely be un-done in the output.
|
47
37
|
#
|
48
|
-
# * to_s, to_xml, to_html, inner_html:
|
38
|
+
# * {#to_s}, {#to_xml}, {#to_html}, {#inner_html}: These methods will all <b>emit
|
39
|
+
# properly-escaped markup</b>, meaning that it's suitable for consumption by browsers,
|
40
|
+
# parsers, etc.
|
49
41
|
#
|
50
|
-
#
|
51
|
-
# that it's suitable for consumption by browsers, parsers, etc.
|
42
|
+
# You may search this node's subtree using {#xpath} and {#css}
|
52
43
|
#
|
53
|
-
# You may search this node's subtree using Searchable#xpath and Searchable#css
|
54
44
|
class Node
|
55
45
|
include Nokogiri::XML::PP::Node
|
56
46
|
include Nokogiri::XML::Searchable
|
57
47
|
include Enumerable
|
58
48
|
|
59
|
-
# Element node type, see Nokogiri::XML::Node#element?
|
49
|
+
# Element node type, see {Nokogiri::XML::Node#element?}
|
60
50
|
ELEMENT_NODE = 1
|
61
51
|
# Attribute node type
|
62
52
|
ATTRIBUTE_NODE = 2
|
63
|
-
# Text node type, see Nokogiri::XML::Node#text?
|
53
|
+
# Text node type, see {Nokogiri::XML::Node#text?}
|
64
54
|
TEXT_NODE = 3
|
65
|
-
# CDATA node type, see Nokogiri::XML::Node#cdata?
|
55
|
+
# CDATA node type, see {Nokogiri::XML::Node#cdata?}
|
66
56
|
CDATA_SECTION_NODE = 4
|
67
57
|
# Entity reference node type
|
68
58
|
ENTITY_REF_NODE = 5
|
@@ -70,9 +60,9 @@ module Nokogiri
|
|
70
60
|
ENTITY_NODE = 6
|
71
61
|
# PI node type
|
72
62
|
PI_NODE = 7
|
73
|
-
# Comment node type, see Nokogiri::XML::Node#comment?
|
63
|
+
# Comment node type, see {Nokogiri::XML::Node#comment?}
|
74
64
|
COMMENT_NODE = 8
|
75
|
-
# Document node type, see Nokogiri::XML::Node#xml?
|
65
|
+
# Document node type, see {Nokogiri::XML::Node#xml?}
|
76
66
|
DOCUMENT_NODE = 9
|
77
67
|
# Document type node type
|
78
68
|
DOCUMENT_TYPE_NODE = 10
|
@@ -80,7 +70,7 @@ module Nokogiri
|
|
80
70
|
DOCUMENT_FRAG_NODE = 11
|
81
71
|
# Notation node type
|
82
72
|
NOTATION_NODE = 12
|
83
|
-
# HTML document node type, see Nokogiri::XML::Node#html?
|
73
|
+
# HTML document node type, see {Nokogiri::XML::Node#html?}
|
84
74
|
HTML_DOCUMENT_NODE = 13
|
85
75
|
# DTD node type
|
86
76
|
DTD_NODE = 14
|
@@ -99,8 +89,15 @@ module Nokogiri
|
|
99
89
|
# DOCB document node type
|
100
90
|
DOCB_DOCUMENT_NODE = 21
|
101
91
|
|
102
|
-
|
103
|
-
|
92
|
+
##
|
93
|
+
# Create a new node with +name+ sharing GC lifecycle with +document+.
|
94
|
+
# @param name [String]
|
95
|
+
# @param document [Nokogiri::XML::Document]
|
96
|
+
# @yieldparam node [Nokogiri::XML::Node]
|
97
|
+
# @return [Nokogiri::XML::Node]
|
98
|
+
# @see Nokogiri::XML::Node.new
|
99
|
+
def initialize(name, document)
|
100
|
+
# This is intentionally empty.
|
104
101
|
end
|
105
102
|
|
106
103
|
###
|
data/lib/nokogiri/xml/reader.rb
CHANGED
@@ -86,7 +86,8 @@ module Nokogiri
|
|
86
86
|
private :initialize
|
87
87
|
|
88
88
|
###
|
89
|
-
# Get
|
89
|
+
# Get the attributes of the current node as a Hash
|
90
|
+
# @return [Hash<String, String>] Attribute names and values
|
90
91
|
def attributes
|
91
92
|
attrs_hash = attribute_nodes.each_with_object({}) do |node, hash|
|
92
93
|
hash[node.name] = node.to_s
|
@@ -96,14 +97,6 @@ module Nokogiri
|
|
96
97
|
attrs_hash
|
97
98
|
end
|
98
99
|
|
99
|
-
###
|
100
|
-
# Get a list of attributes for the current node
|
101
|
-
def attribute_nodes
|
102
|
-
nodes = attr_nodes
|
103
|
-
nodes.each { |v| v.instance_variable_set(:@_r, self) }
|
104
|
-
nodes
|
105
|
-
end
|
106
|
-
|
107
100
|
###
|
108
101
|
# Move the cursor through the document yielding the cursor to the block
|
109
102
|
def each
|
data/lib/nokogiri/xml/xpath.rb
CHANGED
File without changes
|
File without changes
|
@@ -16,7 +16,7 @@ index cf96d41..1372d8b 100644
|
|
16
16
|
}
|
17
17
|
|
18
18
|
-libxml2.la: $(libxml2_la_OBJECTS) $(libxml2_la_DEPENDENCIES) $(EXTRA_libxml2_la_DEPENDENCIES)
|
19
|
-
+$(top_builddir)/libxml2.la: $(libxml2_la_OBJECTS) $(libxml2_la_DEPENDENCIES) $(EXTRA_libxml2_la_DEPENDENCIES)
|
19
|
+
+$(top_builddir)/libxml2.la: $(libxml2_la_OBJECTS) $(libxml2_la_DEPENDENCIES) $(EXTRA_libxml2_la_DEPENDENCIES)
|
20
20
|
$(AM_V_CCLD)$(libxml2_la_LINK) -rpath $(libdir) $(libxml2_la_OBJECTS) $(libxml2_la_LIBADD) $(LIBS)
|
21
21
|
|
22
22
|
testdso.la: $(testdso_la_OBJECTS) $(testdso_la_DEPENDENCIES) $(EXTRA_testdso_la_DEPENDENCIES)
|
File without changes
|
@@ -0,0 +1,81 @@
|
|
1
|
+
This patch is a result of rake-compiler-dock using centos 7 (manylinux2014) to cross-compile.
|
2
|
+
|
3
|
+
Centos, for reasons I have not been able to discern, implements `isnan` and `isinf` as a function
|
4
|
+
and not as a macro. Debian knows how to resolve that function at dynamic-link time (despite using a
|
5
|
+
macro at compile time), but musl-based systems (like alpine) do not. Running `nm` on nokogiri.so
|
6
|
+
created on such a centos system shows:
|
7
|
+
|
8
|
+
```
|
9
|
+
U __isinf@@GLIBC_2.2.5
|
10
|
+
U __isnan@@GLIBC_2.2.5
|
11
|
+
```
|
12
|
+
|
13
|
+
(see https://github.com/sparklemotion/nokogiri/pull/2142 for more info)
|
14
|
+
|
15
|
+
This patch avoids using glibc's `isnan` and `isinf` calls, instead using libxml2's fallback
|
16
|
+
implementation. There's history here, see libxml2 commit 8813f39:
|
17
|
+
|
18
|
+
commit 8813f39
|
19
|
+
Author: Nick Wellnhofer <wellnhofer@aevum.de>
|
20
|
+
Date: 2017-09-21 00:11:26 +0200
|
21
|
+
|
22
|
+
Simplify XPath NaN, inf and -0 handling
|
23
|
+
|
24
|
+
Use C99 macros NAN, INFINITY, isnan, isinf. If they're not available:
|
25
|
+
|
26
|
+
- Assume that (0.0 / 0.0) generates a NaN and !(x == x) tests for NaN.
|
27
|
+
- Use C89's HUGE_VAL for INFINITY.
|
28
|
+
|
29
|
+
Remove manual handling of NaN, infinity and negative zero in functions
|
30
|
+
xmlXPathValueFlipSign and xmlXPathDivValues.
|
31
|
+
|
32
|
+
Remove xmlXPathGetSign. All the tests for negative zero can be replaced
|
33
|
+
with a test for negative or positive zero.
|
34
|
+
|
35
|
+
Simplify xmlXPathRoundFunction.
|
36
|
+
|
37
|
+
Remove Trio dependency.
|
38
|
+
|
39
|
+
This should work on IEEE 754 compliant implementations even if the C99
|
40
|
+
macros aren't available, but will likely break some ancient platforms.
|
41
|
+
If problems arise, my plan is to port the relevant trionan.c solution
|
42
|
+
to xpath.c. Note that non-compliant implementations are impossible
|
43
|
+
to fully support, anyway, since XPath requires IEEE 754.
|
44
|
+
|
45
|
+
This patch would be unnecessary if any of the following was true:
|
46
|
+
|
47
|
+
* centos implements these as macros, and doesn't generate an unresolved symbol for either in the shared library
|
48
|
+
* we had a way to ensure `__isinf` and `__isnan` resolve on musl (e.g., we implement them locally)
|
49
|
+
|
50
|
+
diff --git a/xpath.c b/xpath.c
|
51
|
+
index 9f64ab9..5b6d999 100644
|
52
|
+
--- a/xpath.c
|
53
|
+
+++ b/xpath.c
|
54
|
+
@@ -515,11 +515,7 @@ xmlXPathInit(void) {
|
55
|
+
*/
|
56
|
+
int
|
57
|
+
xmlXPathIsNaN(double val) {
|
58
|
+
-#ifdef isnan
|
59
|
+
- return isnan(val);
|
60
|
+
-#else
|
61
|
+
return !(val == val);
|
62
|
+
-#endif
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
@@ -530,15 +530,11 @@ xmlXPathIsNaN(double val) {
|
67
|
+
*/
|
68
|
+
int
|
69
|
+
xmlXPathIsInf(double val) {
|
70
|
+
-#ifdef isinf
|
71
|
+
- return isinf(val) ? (val > 0 ? 1 : -1) : 0;
|
72
|
+
-#else
|
73
|
+
if (val >= xmlXPathPINF)
|
74
|
+
return 1;
|
75
|
+
if (val <= -xmlXPathPINF)
|
76
|
+
return -1;
|
77
|
+
return 0;
|
78
|
+
-#endif
|
79
|
+
}
|
80
|
+
|
81
|
+
#endif /* SCHEMAS or XPATH */
|