nokogiri 1.12.5-x86_64-darwin → 1.13.3-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 +2 -0
- data/README.md +9 -7
- data/bin/nokogiri +63 -50
- data/dependencies.yml +11 -62
- data/ext/nokogiri/extconf.rb +64 -37
- data/ext/nokogiri/include/libexslt/exslt.h +6 -0
- data/ext/nokogiri/include/libexslt/exsltconfig.h +1 -1
- data/ext/nokogiri/include/libexslt/exsltexports.h +3 -3
- data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +1 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +5 -5
- data/ext/nokogiri/include/libxslt/extensions.h +1 -1
- data/ext/nokogiri/include/libxslt/preproc.h +1 -1
- data/ext/nokogiri/include/libxslt/xsltInternals.h +15 -11
- data/ext/nokogiri/include/libxslt/xsltconfig.h +4 -4
- 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 +638 -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 +32 -32
- data/lib/nokogiri/xml/cdata.rb +2 -1
- data/lib/nokogiri/xml/character_data.rb +1 -0
- data/lib/nokogiri/xml/document.rb +139 -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 +6 -3
- 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
@@ -1,28 +1,39 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Nokogiri
|
3
4
|
module XML
|
4
5
|
class DocumentFragment < Nokogiri::XML::Node
|
6
|
+
####
|
7
|
+
# Create a Nokogiri::XML::DocumentFragment from +tags+
|
8
|
+
def self.parse(tags, options = ParseOptions::DEFAULT_XML, &block)
|
9
|
+
new(XML::Document.new, tags, nil, options, &block)
|
10
|
+
end
|
11
|
+
|
5
12
|
##
|
6
13
|
# Create a new DocumentFragment from +tags+.
|
7
14
|
#
|
8
15
|
# If +ctx+ is present, it is used as a context node for the
|
9
16
|
# subtree created, e.g., namespaces will be resolved relative
|
10
17
|
# to +ctx+.
|
11
|
-
def initialize
|
18
|
+
def initialize(document, tags = nil, ctx = nil, options = ParseOptions::DEFAULT_XML)
|
12
19
|
return self unless tags
|
13
20
|
|
21
|
+
options = Nokogiri::XML::ParseOptions.new(options) if Integer === options
|
22
|
+
yield options if block_given?
|
23
|
+
|
14
24
|
children = if ctx
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
# Fix for issue#490
|
26
|
+
if Nokogiri.jruby?
|
27
|
+
# fix for issue #770
|
28
|
+
ctx.parse("<root #{namespace_declarations(ctx)}>#{tags}</root>", options).children
|
29
|
+
else
|
30
|
+
ctx.parse(tags, options)
|
31
|
+
end
|
32
|
+
else
|
33
|
+
wrapper_doc = XML::Document.parse("<root>#{tags}</root>", nil, nil, options)
|
34
|
+
self.errors = wrapper_doc.errors
|
35
|
+
wrapper_doc.xpath("/root/node()")
|
36
|
+
end
|
26
37
|
children.each { |child| child.parent = self }
|
27
38
|
end
|
28
39
|
|
@@ -40,7 +51,7 @@ module Nokogiri
|
|
40
51
|
###
|
41
52
|
# return the name for DocumentFragment
|
42
53
|
def name
|
43
|
-
|
54
|
+
"#document-fragment"
|
44
55
|
end
|
45
56
|
|
46
57
|
###
|
@@ -52,10 +63,10 @@ module Nokogiri
|
|
52
63
|
###
|
53
64
|
# Convert this DocumentFragment to html
|
54
65
|
# See Nokogiri::XML::NodeSet#to_html
|
55
|
-
def to_html
|
66
|
+
def to_html(*args)
|
56
67
|
if Nokogiri.jruby?
|
57
68
|
options = args.first.is_a?(Hash) ? args.shift : {}
|
58
|
-
|
69
|
+
unless options[:save_with]
|
59
70
|
options[:save_with] = Node::SaveOptions::NO_DECLARATION | Node::SaveOptions::NO_EMPTY_TAGS | Node::SaveOptions::AS_HTML
|
60
71
|
end
|
61
72
|
args.insert(0, options)
|
@@ -66,10 +77,10 @@ module Nokogiri
|
|
66
77
|
###
|
67
78
|
# Convert this DocumentFragment to xhtml
|
68
79
|
# See Nokogiri::XML::NodeSet#to_xhtml
|
69
|
-
def to_xhtml
|
80
|
+
def to_xhtml(*args)
|
70
81
|
if Nokogiri.jruby?
|
71
82
|
options = args.first.is_a?(Hash) ? args.shift : {}
|
72
|
-
|
83
|
+
unless options[:save_with]
|
73
84
|
options[:save_with] = Node::SaveOptions::NO_DECLARATION | Node::SaveOptions::NO_EMPTY_TAGS | Node::SaveOptions::AS_XHTML
|
74
85
|
end
|
75
86
|
args.insert(0, options)
|
@@ -80,7 +91,7 @@ module Nokogiri
|
|
80
91
|
###
|
81
92
|
# Convert this DocumentFragment to xml
|
82
93
|
# See Nokogiri::XML::NodeSet#to_xml
|
83
|
-
def to_xml
|
94
|
+
def to_xml(*args)
|
84
95
|
children.to_xml(*args)
|
85
96
|
end
|
86
97
|
|
@@ -91,7 +102,7 @@ module Nokogiri
|
|
91
102
|
# selectors. For example:
|
92
103
|
#
|
93
104
|
# For more information see Nokogiri::XML::Searchable#css
|
94
|
-
def css
|
105
|
+
def css(*args)
|
95
106
|
if children.any?
|
96
107
|
children.css(*args) # 'children' is a smell here
|
97
108
|
else
|
@@ -110,34 +121,26 @@ module Nokogiri
|
|
110
121
|
# Search this fragment for +paths+. +paths+ must be one or more XPath or CSS queries.
|
111
122
|
#
|
112
123
|
# For more information see Nokogiri::XML::Searchable#search
|
113
|
-
def search
|
124
|
+
def search(*rules)
|
114
125
|
rules, handler, ns, binds = extract_params(rules)
|
115
126
|
|
116
127
|
rules.inject(NodeSet.new(document)) do |set, rule|
|
117
|
-
set
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
128
|
+
set + if Searchable::LOOKS_LIKE_XPATH.match?(rule)
|
129
|
+
xpath(*[rule, ns, handler, binds].compact)
|
130
|
+
else
|
131
|
+
children.css(*[rule, ns, handler].compact) # 'children' is a smell here
|
132
|
+
end
|
122
133
|
end
|
123
134
|
end
|
124
135
|
|
125
|
-
|
126
|
-
|
127
|
-
class << self
|
128
|
-
####
|
129
|
-
# Create a Nokogiri::XML::DocumentFragment from +tags+
|
130
|
-
def parse tags
|
131
|
-
self.new(XML::Document.new, tags)
|
132
|
-
end
|
133
|
-
end
|
136
|
+
alias_method :serialize, :to_s
|
134
137
|
|
135
138
|
# A list of Nokogiri::XML::SyntaxError found when parsing a document
|
136
139
|
def errors
|
137
140
|
document.errors
|
138
141
|
end
|
139
142
|
|
140
|
-
def errors=
|
143
|
+
def errors=(things) # :nodoc:
|
141
144
|
document.errors = things
|
142
145
|
end
|
143
146
|
|
@@ -148,11 +151,11 @@ module Nokogiri
|
|
148
151
|
private
|
149
152
|
|
150
153
|
# fix for issue 770
|
151
|
-
def namespace_declarations
|
154
|
+
def namespace_declarations(ctx)
|
152
155
|
ctx.namespace_scopes.map do |namespace|
|
153
156
|
prefix = namespace.prefix.nil? ? "" : ":#{namespace.prefix}"
|
154
|
-
%
|
155
|
-
end.join
|
157
|
+
%{xmlns#{prefix}="#{namespace.href}"}
|
158
|
+
end.join(" ")
|
156
159
|
end
|
157
160
|
end
|
158
161
|
end
|
data/lib/nokogiri/xml/dtd.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Nokogiri
|
3
4
|
module XML
|
4
5
|
class DTD < Nokogiri::XML::Node
|
@@ -20,13 +21,13 @@ module Nokogiri
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def html_dtd?
|
23
|
-
name.casecmp(
|
24
|
+
name.casecmp("html").zero?
|
24
25
|
end
|
25
26
|
|
26
27
|
def html5_dtd?
|
27
28
|
html_dtd? &&
|
28
29
|
external_id.nil? &&
|
29
|
-
(system_id.nil? || system_id ==
|
30
|
+
(system_id.nil? || system_id == "about:legacy-compat")
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Nokogiri
|
3
4
|
module XML
|
4
5
|
class ElementDecl < Nokogiri::XML::Node
|
@@ -7,7 +8,7 @@ module Nokogiri
|
|
7
8
|
undef_method :line if method_defined?(:line)
|
8
9
|
|
9
10
|
def inspect
|
10
|
-
"#<#{self.class.name}:#{
|
11
|
+
"#<#{self.class.name}:#{format("0x%x", object_id)} #{to_s.inspect}>"
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Nokogiri
|
3
4
|
module XML
|
4
5
|
class EntityDecl < Nokogiri::XML::Node
|
@@ -8,12 +9,12 @@ module Nokogiri
|
|
8
9
|
undef_method :namespace_definitions
|
9
10
|
undef_method :line if method_defined?(:line)
|
10
11
|
|
11
|
-
def self.new
|
12
|
+
def self.new(name, doc, *args)
|
12
13
|
doc.create_entity(name, *args)
|
13
14
|
end
|
14
15
|
|
15
16
|
def inspect
|
16
|
-
"#<#{self.class.name}:#{
|
17
|
+
"#<#{self.class.name}:#{format("0x%x", object_id)} #{to_s.inspect}>"
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Nokogiri
|
3
4
|
module XML
|
4
5
|
class Node
|
@@ -22,7 +23,7 @@ module Nokogiri
|
|
22
23
|
|
23
24
|
if Nokogiri.jruby?
|
24
25
|
# Save builder created document
|
25
|
-
AS_BUILDER
|
26
|
+
AS_BUILDER = 128
|
26
27
|
# the default for XML documents
|
27
28
|
DEFAULT_XML = AS_XML # https://github.com/sparklemotion/nokogiri/issues/#issue/415
|
28
29
|
# the default for HTML document
|
@@ -40,7 +41,9 @@ module Nokogiri
|
|
40
41
|
attr_reader :options
|
41
42
|
|
42
43
|
# Create a new SaveOptions object with +options+
|
43
|
-
def initialize
|
44
|
+
def initialize(options = 0)
|
45
|
+
@options = options
|
46
|
+
end
|
44
47
|
|
45
48
|
constants.each do |constant|
|
46
49
|
class_eval %{
|
@@ -55,7 +58,7 @@ module Nokogiri
|
|
55
58
|
}
|
56
59
|
end
|
57
60
|
|
58
|
-
|
61
|
+
alias_method :to_i, :options
|
59
62
|
end
|
60
63
|
end
|
61
64
|
end
|