nokogiri 1.11.2-x64-mingw32 → 1.11.3-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/LICENSE.md +1 -1
- data/README.md +1 -1
- data/ext/nokogiri/xml_document.c +36 -35
- data/ext/nokogiri/xml_node.c +37 -38
- 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/document.rb +43 -17
- data/lib/nokogiri/xml/node.rb +1 -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: 5a7f3fe2e2340e5f70277962b3a328c39a3fd7b197e099a8fa0846f514ae3ec4
|
4
|
+
data.tar.gz: c90d3a517e0e98e02809e7330b9b8955a825d0d9d206dedc82f5d0b9c275c920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ff57d13f1a1b35673d5a24f2dfa610b7529a715139abe860b5bb540839b1db3838ddc699bbb429d1bca28981392d3ff91d4d81b8d2ab4603cc9965e6096c05c
|
7
|
+
data.tar.gz: 238c9810868256feef73248076569365192979fc0b081931ac7ff5b60f5a458029798367214554db4074ab35463d4aec4688b1263e6819b396ba3e0c5933744a
|
data/LICENSE.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License
|
2
2
|
|
3
|
-
Copyright 2008 --
|
3
|
+
Copyright 2008 -- 2021 by Mike Dalessio, Aaron Patterson, Yoko Harada, Akinori MUSHA, John Shahid, Karol Bucek, Lars Kanis, Sergio Arbeo, Timothy Elliott, Nobuyoshi Nakada, Charles Nutter, Patrick Mahoney.
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
6
|
|
data/README.md
CHANGED
@@ -57,7 +57,7 @@ Your first stops for learning more about Nokogiri should be:
|
|
57
57
|
|
58
58
|
There are a few ways to ask exploratory questions:
|
59
59
|
|
60
|
-
- The Discord chat
|
60
|
+
- The Ruby Discord chat server is active at https://discord.gg/UyQnKrT
|
61
61
|
- The Nokogiri mailing list is active at https://groups.google.com/group/nokogiri-talk
|
62
62
|
- Open an issue using the "Help Request" template at https://github.com/sparklemotion/nokogiri/issues
|
63
63
|
|
data/ext/nokogiri/xml_document.c
CHANGED
@@ -141,42 +141,41 @@ url(VALUE self)
|
|
141
141
|
* Set the root element on this document
|
142
142
|
*/
|
143
143
|
static VALUE
|
144
|
-
|
144
|
+
rb_xml_document_root_set(VALUE self, VALUE rb_new_root)
|
145
145
|
{
|
146
|
-
xmlDocPtr
|
147
|
-
xmlNodePtr
|
148
|
-
xmlNodePtr old_root;
|
149
|
-
|
150
|
-
Data_Get_Struct(self, xmlDoc, doc);
|
146
|
+
xmlDocPtr c_document;
|
147
|
+
xmlNodePtr c_new_root = NULL, c_current_root;
|
151
148
|
|
152
|
-
|
153
|
-
|
154
|
-
if (NIL_P(root)) {
|
155
|
-
old_root = xmlDocGetRootElement(doc);
|
156
|
-
|
157
|
-
if (old_root) {
|
158
|
-
xmlUnlinkNode(old_root);
|
159
|
-
noko_xml_document_pin_node(old_root);
|
160
|
-
}
|
149
|
+
Data_Get_Struct(self, xmlDoc, c_document);
|
161
150
|
|
162
|
-
|
151
|
+
c_current_root = xmlDocGetRootElement(c_document);
|
152
|
+
if (c_current_root) {
|
153
|
+
xmlUnlinkNode(c_current_root);
|
154
|
+
noko_xml_document_pin_node(c_current_root);
|
163
155
|
}
|
164
156
|
|
165
|
-
|
157
|
+
if (!NIL_P(rb_new_root)) {
|
158
|
+
if (!rb_obj_is_kind_of(rb_new_root, cNokogiriXmlNode)) {
|
159
|
+
rb_raise(rb_eArgError,
|
160
|
+
"expected Nokogiri::XML::Node but received %"PRIsVALUE,
|
161
|
+
rb_obj_class(rb_new_root));
|
162
|
+
}
|
166
163
|
|
164
|
+
Data_Get_Struct(rb_new_root, xmlNode, c_new_root);
|
167
165
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
166
|
+
/* If the new root's document is not the same as the current document,
|
167
|
+
* then we need to dup the node in to this document. */
|
168
|
+
if (c_new_root->doc != c_document) {
|
169
|
+
c_new_root = xmlDocCopyNode(c_new_root, c_document, 1);
|
170
|
+
if (!c_new_root) {
|
171
|
+
rb_raise(rb_eRuntimeError, "Could not reparent node (xmlDocCopyNode)");
|
172
|
+
}
|
174
173
|
}
|
175
174
|
}
|
176
175
|
|
177
|
-
xmlDocSetRootElement(
|
178
|
-
|
179
|
-
return
|
176
|
+
xmlDocSetRootElement(c_document, c_new_root);
|
177
|
+
|
178
|
+
return rb_new_root;
|
180
179
|
}
|
181
180
|
|
182
181
|
/*
|
@@ -186,17 +185,19 @@ set_root(VALUE self, VALUE root)
|
|
186
185
|
* Get the root node for this document.
|
187
186
|
*/
|
188
187
|
static VALUE
|
189
|
-
|
188
|
+
rb_xml_document_root(VALUE self)
|
190
189
|
{
|
191
|
-
xmlDocPtr
|
192
|
-
xmlNodePtr
|
190
|
+
xmlDocPtr c_document;
|
191
|
+
xmlNodePtr c_root;
|
193
192
|
|
194
|
-
Data_Get_Struct(self, xmlDoc,
|
193
|
+
Data_Get_Struct(self, xmlDoc, c_document);
|
195
194
|
|
196
|
-
|
195
|
+
c_root = xmlDocGetRootElement(c_document);
|
196
|
+
if (!c_root) {
|
197
|
+
return Qnil;
|
198
|
+
}
|
197
199
|
|
198
|
-
|
199
|
-
return noko_xml_node_wrap(Qnil, root) ;
|
200
|
+
return noko_xml_node_wrap(Qnil, c_root) ;
|
200
201
|
}
|
201
202
|
|
202
203
|
/*
|
@@ -666,8 +667,8 @@ noko_init_xml_document()
|
|
666
667
|
rb_define_singleton_method(cNokogiriXmlDocument, "read_io", read_io, 4);
|
667
668
|
rb_define_singleton_method(cNokogiriXmlDocument, "new", new, -1);
|
668
669
|
|
669
|
-
rb_define_method(cNokogiriXmlDocument, "root",
|
670
|
-
rb_define_method(cNokogiriXmlDocument, "root=",
|
670
|
+
rb_define_method(cNokogiriXmlDocument, "root", rb_xml_document_root, 0);
|
671
|
+
rb_define_method(cNokogiriXmlDocument, "root=", rb_xml_document_root_set, 1);
|
671
672
|
rb_define_method(cNokogiriXmlDocument, "encoding", encoding, 0);
|
672
673
|
rb_define_method(cNokogiriXmlDocument, "encoding=", set_encoding, 1);
|
673
674
|
rb_define_method(cNokogiriXmlDocument, "version", version, 0);
|
data/ext/nokogiri/xml_node.c
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
VALUE cNokogiriXmlNode ;
|
4
4
|
|
5
|
-
static ID
|
5
|
+
static ID id_decorate, id_decorate_bang;
|
6
6
|
|
7
7
|
#ifdef DEBUG
|
8
8
|
static void
|
@@ -357,7 +357,7 @@ ok:
|
|
357
357
|
|
358
358
|
reparented_obj = noko_xml_node_wrap(Qnil, reparented);
|
359
359
|
|
360
|
-
rb_funcall(reparented_obj,
|
360
|
+
rb_funcall(reparented_obj, id_decorate_bang, 0);
|
361
361
|
|
362
362
|
return reparented_obj ;
|
363
363
|
}
|
@@ -1443,6 +1443,7 @@ add_namespace_definition(VALUE rb_node, VALUE rb_prefix, VALUE rb_href)
|
|
1443
1443
|
* Create a new node with +name+ sharing GC lifecycle with +document+.
|
1444
1444
|
* @param name [String]
|
1445
1445
|
* @param document [Nokogiri::XML::Document]
|
1446
|
+
* @yieldparam node [Nokogiri::XML::Node]
|
1446
1447
|
* @return [Nokogiri::XML::Node]
|
1447
1448
|
* @see Nokogiri::XML::Node#initialize
|
1448
1449
|
*/
|
@@ -1655,85 +1656,83 @@ in_context(VALUE self, VALUE _str, VALUE _options)
|
|
1655
1656
|
|
1656
1657
|
|
1657
1658
|
VALUE
|
1658
|
-
noko_xml_node_wrap(VALUE
|
1659
|
+
noko_xml_node_wrap(VALUE rb_class, xmlNodePtr c_node)
|
1659
1660
|
{
|
1660
|
-
VALUE
|
1661
|
-
VALUE node_cache = Qnil ;
|
1662
|
-
VALUE rb_node = Qnil ;
|
1661
|
+
VALUE rb_document, rb_node_cache, rb_node;
|
1663
1662
|
nokogiriTuplePtr node_has_a_document;
|
1664
|
-
xmlDocPtr
|
1663
|
+
xmlDocPtr c_doc;
|
1665
1664
|
void (*mark_method)(xmlNodePtr) = NULL ;
|
1666
1665
|
|
1667
|
-
assert(
|
1666
|
+
assert(c_node);
|
1668
1667
|
|
1669
|
-
if (
|
1670
|
-
return DOC_RUBY_OBJECT(
|
1668
|
+
if (c_node->type == XML_DOCUMENT_NODE || c_node->type == XML_HTML_DOCUMENT_NODE) {
|
1669
|
+
return DOC_RUBY_OBJECT(c_node->doc);
|
1671
1670
|
}
|
1672
1671
|
|
1673
1672
|
/* It's OK if the node doesn't have a fully-realized document (as in XML::Reader). */
|
1674
1673
|
/* see https://github.com/sparklemotion/nokogiri/issues/95 */
|
1675
1674
|
/* and https://github.com/sparklemotion/nokogiri/issues/439 */
|
1676
|
-
|
1677
|
-
if (
|
1678
|
-
node_has_a_document = DOC_RUBY_OBJECT_TEST(
|
1675
|
+
c_doc = c_node->doc;
|
1676
|
+
if (c_doc->type == XML_DOCUMENT_FRAG_NODE) { c_doc = c_doc->doc; }
|
1677
|
+
node_has_a_document = DOC_RUBY_OBJECT_TEST(c_doc);
|
1679
1678
|
|
1680
|
-
if (
|
1681
|
-
return (VALUE)
|
1679
|
+
if (c_node->_private && node_has_a_document) {
|
1680
|
+
return (VALUE)c_node->_private;
|
1682
1681
|
}
|
1683
1682
|
|
1684
|
-
if (!RTEST(
|
1685
|
-
switch (
|
1683
|
+
if (!RTEST(rb_class)) {
|
1684
|
+
switch (c_node->type) {
|
1686
1685
|
case XML_ELEMENT_NODE:
|
1687
|
-
|
1686
|
+
rb_class = cNokogiriXmlElement;
|
1688
1687
|
break;
|
1689
1688
|
case XML_TEXT_NODE:
|
1690
|
-
|
1689
|
+
rb_class = cNokogiriXmlText;
|
1691
1690
|
break;
|
1692
1691
|
case XML_ATTRIBUTE_NODE:
|
1693
|
-
|
1692
|
+
rb_class = cNokogiriXmlAttr;
|
1694
1693
|
break;
|
1695
1694
|
case XML_ENTITY_REF_NODE:
|
1696
|
-
|
1695
|
+
rb_class = cNokogiriXmlEntityReference;
|
1697
1696
|
break;
|
1698
1697
|
case XML_COMMENT_NODE:
|
1699
|
-
|
1698
|
+
rb_class = cNokogiriXmlComment;
|
1700
1699
|
break;
|
1701
1700
|
case XML_DOCUMENT_FRAG_NODE:
|
1702
|
-
|
1701
|
+
rb_class = cNokogiriXmlDocumentFragment;
|
1703
1702
|
break;
|
1704
1703
|
case XML_PI_NODE:
|
1705
|
-
|
1704
|
+
rb_class = cNokogiriXmlProcessingInstruction;
|
1706
1705
|
break;
|
1707
1706
|
case XML_ENTITY_DECL:
|
1708
|
-
|
1707
|
+
rb_class = cNokogiriXmlEntityDecl;
|
1709
1708
|
break;
|
1710
1709
|
case XML_CDATA_SECTION_NODE:
|
1711
|
-
|
1710
|
+
rb_class = cNokogiriXmlCData;
|
1712
1711
|
break;
|
1713
1712
|
case XML_DTD_NODE:
|
1714
|
-
|
1713
|
+
rb_class = cNokogiriXmlDtd;
|
1715
1714
|
break;
|
1716
1715
|
case XML_ATTRIBUTE_DECL:
|
1717
|
-
|
1716
|
+
rb_class = cNokogiriXmlAttributeDecl;
|
1718
1717
|
break;
|
1719
1718
|
case XML_ELEMENT_DECL:
|
1720
|
-
|
1719
|
+
rb_class = cNokogiriXmlElementDecl;
|
1721
1720
|
break;
|
1722
1721
|
default:
|
1723
|
-
|
1722
|
+
rb_class = cNokogiriXmlNode;
|
1724
1723
|
}
|
1725
1724
|
}
|
1726
1725
|
|
1727
1726
|
mark_method = node_has_a_document ? mark : NULL ;
|
1728
1727
|
|
1729
|
-
rb_node = Data_Wrap_Struct(
|
1730
|
-
|
1728
|
+
rb_node = Data_Wrap_Struct(rb_class, mark_method, debug_node_dealloc, c_node) ;
|
1729
|
+
c_node->_private = (void *)rb_node;
|
1731
1730
|
|
1732
1731
|
if (node_has_a_document) {
|
1733
|
-
|
1734
|
-
|
1735
|
-
rb_ary_push(
|
1736
|
-
rb_funcall(
|
1732
|
+
rb_document = DOC_RUBY_OBJECT(c_doc);
|
1733
|
+
rb_node_cache = DOC_NODE_CACHE(c_doc);
|
1734
|
+
rb_ary_push(rb_node_cache, rb_node);
|
1735
|
+
rb_funcall(rb_document, id_decorate, 1, rb_node);
|
1737
1736
|
}
|
1738
1737
|
|
1739
1738
|
return rb_node ;
|
@@ -1818,8 +1817,8 @@ noko_init_xml_node()
|
|
1818
1817
|
rb_define_private_method(cNokogiriXmlNode, "set_namespace", set_namespace, 1);
|
1819
1818
|
rb_define_private_method(cNokogiriXmlNode, "compare", compare, 1);
|
1820
1819
|
|
1821
|
-
|
1822
|
-
|
1820
|
+
id_decorate = rb_intern("decorate");
|
1821
|
+
id_decorate_bang = rb_intern("decorate!");
|
1823
1822
|
}
|
1824
1823
|
|
1825
1824
|
/* vim: set noet sw=4 sws=4 */
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -14,11 +14,12 @@ module Nokogiri
|
|
14
14
|
# Nokogiri::XML::Searchable#xpath
|
15
15
|
#
|
16
16
|
class Document < Nokogiri::XML::Node
|
17
|
-
#
|
18
|
-
#
|
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.
|
19
20
|
NCNAME_START_CHAR = "A-Za-z_"
|
20
|
-
NCNAME_CHAR = NCNAME_START_CHAR + "
|
21
|
-
NCNAME_RE = /^xmlns(
|
21
|
+
NCNAME_CHAR = NCNAME_START_CHAR + "\\-\\.0-9"
|
22
|
+
NCNAME_RE = /^xmlns(?::([#{NCNAME_START_CHAR}][#{NCNAME_CHAR}]*))?$/
|
22
23
|
|
23
24
|
##
|
24
25
|
# Parse an XML file.
|
@@ -118,33 +119,58 @@ module Nokogiri
|
|
118
119
|
end
|
119
120
|
|
120
121
|
##
|
121
|
-
# Create
|
122
|
+
# Create a new +Element+ with +name+ sharing GC lifecycle with the document, optionally
|
123
|
+
# setting contents or attributes.
|
122
124
|
#
|
123
|
-
#
|
124
|
-
#
|
125
|
-
#
|
126
|
-
# doc.create_element "div", "contents", :class => "container" # <div class='container'>contents</div>
|
127
|
-
# doc.create_element "div" { |node| node['class'] = "container" } # <div class='container'></div>
|
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
|
128
128
|
#
|
129
|
-
|
129
|
+
# A block may be passed to mutate the node.
|
130
|
+
#
|
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)
|
130
156
|
elm = Nokogiri::XML::Element.new(name, self, &block)
|
131
|
-
|
157
|
+
contents_or_attrs.each do |arg|
|
132
158
|
case arg
|
133
159
|
when Hash
|
134
|
-
arg.each
|
160
|
+
arg.each do |k, v|
|
135
161
|
key = k.to_s
|
136
162
|
if key =~ NCNAME_RE
|
137
|
-
ns_name =
|
138
|
-
elm.add_namespace_definition
|
163
|
+
ns_name = Regexp.last_match(1)
|
164
|
+
elm.add_namespace_definition(ns_name, v)
|
139
165
|
else
|
140
166
|
elm[k.to_s] = v.to_s
|
141
167
|
end
|
142
|
-
|
168
|
+
end
|
143
169
|
else
|
144
170
|
elm.content = arg
|
145
171
|
end
|
146
172
|
end
|
147
|
-
if ns = elm.namespace_definitions.find { |n| n.prefix.nil?
|
173
|
+
if ns = elm.namespace_definitions.find { |n| n.prefix.nil? || (n.prefix == '') }
|
148
174
|
elm.namespace = ns
|
149
175
|
end
|
150
176
|
elm
|
data/lib/nokogiri/xml/node.rb
CHANGED
@@ -93,6 +93,7 @@ module Nokogiri
|
|
93
93
|
# Create a new node with +name+ sharing GC lifecycle with +document+.
|
94
94
|
# @param name [String]
|
95
95
|
# @param document [Nokogiri::XML::Document]
|
96
|
+
# @yieldparam node [Nokogiri::XML::Node]
|
96
97
|
# @return [Nokogiri::XML::Node]
|
97
98
|
# @see Nokogiri::XML::Node.new
|
98
99
|
def initialize(name, document)
|
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.11.
|
4
|
+
version: 1.11.3
|
5
5
|
platform: x64-mingw32
|
6
6
|
authors:
|
7
7
|
- Mike Dalessio
|
@@ -17,7 +17,7 @@ authors:
|
|
17
17
|
autorequire:
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
|
-
date: 2021-
|
20
|
+
date: 2021-04-07 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: racc
|