nokogiri 1.12.3-x64-mingw32 → 1.12.4-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.
- checksums.yaml +4 -4
- data/ext/nokogiri/xml_node.c +7 -0
- data/lib/nokogiri/2.5/nokogiri.so +0 -0
- data/lib/nokogiri/2.6/nokogiri.so +0 -0
- data/lib/nokogiri/2.7/nokogiri.so +0 -0
- data/lib/nokogiri/3.0/nokogiri.so +0 -0
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +38 -0
- data/lib/nokogiri/xml/document.rb +46 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62fd65c6e73d8084ca56939b646346aaed2bde60b7e6ff8cee75a5b2ca715371
|
4
|
+
data.tar.gz: aaa347627210c78196b6792d0c8da716853ce60e3e4a042866b70435bae4e335
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b704513b074be1ed5986c6d8b06eee8fa84e2c9cc8589598dc91dca5538625168999a359cceb2ec6f8fd4c88c76a8cabe9e97ae9e8fceca46b03f66a63f6bab5
|
7
|
+
data.tar.gz: a50e7ca76bacf12f0aa9a806092ecdf4b4852d41fa4390eca7d4080fac3a490bb39ea92e42e7b7f4e55f945a13f180751a4a770602c6a20dfa2b1e5e351e2309
|
data/ext/nokogiri/xml_node.c
CHANGED
@@ -69,6 +69,13 @@ relink_namespace(xmlNodePtr reparented)
|
|
69
69
|
/* Avoid segv when relinking against unlinked nodes. */
|
70
70
|
if (reparented->type != XML_ELEMENT_NODE || !reparented->parent) { return; }
|
71
71
|
|
72
|
+
/* Make sure that our reparented node has the correct namespaces */
|
73
|
+
if (!reparented->ns &&
|
74
|
+
(reparented->doc != (xmlDocPtr)reparented->parent) &&
|
75
|
+
(rb_iv_get(DOC_RUBY_OBJECT(reparented->doc), "@namespace_inheritance") == Qtrue)) {
|
76
|
+
xmlSetNs(reparented, reparented->parent->ns);
|
77
|
+
}
|
78
|
+
|
72
79
|
/* Search our parents for an existing definition */
|
73
80
|
if (reparented->nsDef) {
|
74
81
|
xmlNsPtr curr = reparented->nsDef;
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/nokogiri/xml/builder.rb
CHANGED
@@ -196,6 +196,41 @@ module Nokogiri
|
|
196
196
|
#
|
197
197
|
# Note the "foo:object" tag.
|
198
198
|
#
|
199
|
+
# === Namespace inheritance
|
200
|
+
#
|
201
|
+
# In the Builder context, children will inherit their parent's namespace. This is the same
|
202
|
+
# behavior as if the underlying {XML::Document} set +namespace_inheritance+ to +true+:
|
203
|
+
#
|
204
|
+
# result = Nokogiri::XML::Builder.new do |xml|
|
205
|
+
# xml["soapenv"].Envelope("xmlns:soapenv" => "http://schemas.xmlsoap.org/soap/envelope/") do
|
206
|
+
# xml.Header
|
207
|
+
# end
|
208
|
+
# end
|
209
|
+
# result.doc.to_xml
|
210
|
+
# # => <?xml version="1.0" encoding="utf-8"?>
|
211
|
+
# # <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
|
212
|
+
# # <soapenv:Header/>
|
213
|
+
# # </soapenv:Envelope>
|
214
|
+
#
|
215
|
+
# Users may turn this behavior off by passing a keyword argument +namespace_inheritance:false+
|
216
|
+
# to the initializer:
|
217
|
+
#
|
218
|
+
# result = Nokogiri::XML::Builder.new(namespace_inheritance: false) do |xml|
|
219
|
+
# xml["soapenv"].Envelope("xmlns:soapenv" => "http://schemas.xmlsoap.org/soap/envelope/") do
|
220
|
+
# xml.Header
|
221
|
+
# xml["soapenv"].Body # users may explicitly opt into the namespace
|
222
|
+
# end
|
223
|
+
# end
|
224
|
+
# result.doc.to_xml
|
225
|
+
# # => <?xml version="1.0" encoding="utf-8"?>
|
226
|
+
# # <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
|
227
|
+
# # <Header/>
|
228
|
+
# # <soapenv:Body/>
|
229
|
+
# # </soapenv:Envelope>
|
230
|
+
#
|
231
|
+
# For more information on namespace inheritance, please see {XML::Document#namespace_inheritance}
|
232
|
+
#
|
233
|
+
#
|
199
234
|
# == Document Types
|
200
235
|
#
|
201
236
|
# To create a document type (DTD), access use the Builder#doc method to get
|
@@ -226,6 +261,8 @@ module Nokogiri
|
|
226
261
|
# </root>
|
227
262
|
#
|
228
263
|
class Builder
|
264
|
+
DEFAULT_DOCUMENT_OPTIONS = {namespace_inheritance: true}
|
265
|
+
|
229
266
|
# The current Document object being built
|
230
267
|
attr_accessor :doc
|
231
268
|
|
@@ -282,6 +319,7 @@ module Nokogiri
|
|
282
319
|
@arity = nil
|
283
320
|
@ns = nil
|
284
321
|
|
322
|
+
options = DEFAULT_DOCUMENT_OPTIONS.merge(options)
|
285
323
|
options.each do |k, v|
|
286
324
|
@doc.send(:"#{k}=", v)
|
287
325
|
end
|
@@ -113,9 +113,55 @@ module Nokogiri
|
|
113
113
|
# A list of Nokogiri::XML::SyntaxError found when parsing a document
|
114
114
|
attr_accessor :errors
|
115
115
|
|
116
|
+
# When true, reparented elements without a namespace will inherit their new parent's
|
117
|
+
# namespace (if one exists). Defaults to +false+.
|
118
|
+
#
|
119
|
+
# @example Default behavior of namespace inheritance
|
120
|
+
# xml = <<~EOF
|
121
|
+
# <root xmlns:foo="http://nokogiri.org/default_ns/test/foo">
|
122
|
+
# <foo:parent>
|
123
|
+
# </foo:parent>
|
124
|
+
# </root>
|
125
|
+
# EOF
|
126
|
+
# doc = Nokogiri::XML(xml)
|
127
|
+
# parent = doc.at_xpath("//foo:parent", "foo" => "http://nokogiri.org/default_ns/test/foo")
|
128
|
+
# parent.add_child("<child></child>")
|
129
|
+
# doc.to_xml
|
130
|
+
# # => <?xml version="1.0"?>
|
131
|
+
# # <root xmlns:foo="http://nokogiri.org/default_ns/test/foo">
|
132
|
+
# # <foo:parent>
|
133
|
+
# # <child/>
|
134
|
+
# # </foo:parent>
|
135
|
+
# # </root>
|
136
|
+
#
|
137
|
+
# @example Setting namespace inheritance to +true+
|
138
|
+
# xml = <<~EOF
|
139
|
+
# <root xmlns:foo="http://nokogiri.org/default_ns/test/foo">
|
140
|
+
# <foo:parent>
|
141
|
+
# </foo:parent>
|
142
|
+
# </root>
|
143
|
+
# EOF
|
144
|
+
# doc = Nokogiri::XML(xml)
|
145
|
+
# doc.namespace_inheritance = true
|
146
|
+
# parent = doc.at_xpath("//foo:parent", "foo" => "http://nokogiri.org/default_ns/test/foo")
|
147
|
+
# parent.add_child("<child></child>")
|
148
|
+
# doc.to_xml
|
149
|
+
# # => <?xml version="1.0"?>
|
150
|
+
# # <root xmlns:foo="http://nokogiri.org/default_ns/test/foo">
|
151
|
+
# # <foo:parent>
|
152
|
+
# # <foo:child/>
|
153
|
+
# # </foo:parent>
|
154
|
+
# # </root>
|
155
|
+
#
|
156
|
+
# @return [Boolean]
|
157
|
+
#
|
158
|
+
# @since v1.12.4
|
159
|
+
attr_accessor :namespace_inheritance
|
160
|
+
|
116
161
|
def initialize *args # :nodoc:
|
117
162
|
@errors = []
|
118
163
|
@decorators = nil
|
164
|
+
@namespace_inheritance = false
|
119
165
|
end
|
120
166
|
|
121
167
|
##
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nokogiri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
4
|
+
version: 1.12.4
|
5
5
|
platform: x64-mingw32
|
6
6
|
authors:
|
7
7
|
- Mike Dalessio
|
@@ -20,7 +20,7 @@ authors:
|
|
20
20
|
autorequire:
|
21
21
|
bindir: bin
|
22
22
|
cert_chain: []
|
23
|
-
date: 2021-08-
|
23
|
+
date: 2021-08-29 00:00:00.000000000 Z
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: racc
|