nokogiri 1.11.2-x86-mingw32 → 1.11.3-x86-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce2baa965360ab349bfbb47dbe2e36388cc27ea6def9ed67786515899773d860
4
- data.tar.gz: 31bd55e990fb4fd369828db83607a95c0699e8badd694663e093b735cdec25f3
3
+ metadata.gz: e62ad88cc701b27df0fa8735bfba8e38908244a7e8a3256c8a07fdf538760434
4
+ data.tar.gz: fe698989d5e05093cf109c4e406854a5c5cde11e4e290bca1fd280297a297f2d
5
5
  SHA512:
6
- metadata.gz: 3ede6cea2d41a948a2762554f3000d6c13f6a2b99b6a6f15ff737178db7f774e801590c6345dc85debd93d992b4be57f4a05e74d944e19846e0577138953d553
7
- data.tar.gz: b5516d211b78d96ee03758e0ff200e854b7c7d2161892de0fb44c9844bf6d4b04cfd5b79057e16c0f440a6cbe9e914bb675b881e0d07f902cc740e3c9c96b3a4
6
+ metadata.gz: a67f1e239605bb31b463319e74e1d6ff05ba02a8535051777d022ead226a3d9393ab112df7f1d8fd5a43616df55a86b5708df7b1e7eef892f0c61be85368b816
7
+ data.tar.gz: 479a2a214ca515a6e8b9c9a9ae1721ba63211d4dfd82148cffa6e8e3edb731ce3c03ac549dc4b15e966b58bcdea7045775206582c60204887b52c2aebf725539
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright 2008 -- 2020 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.
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 channel is `#nokogiri-💎` at https://discord.gg/UyQnKrT
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
 
@@ -141,42 +141,41 @@ url(VALUE self)
141
141
  * Set the root element on this document
142
142
  */
143
143
  static VALUE
144
- set_root(VALUE self, VALUE root)
144
+ rb_xml_document_root_set(VALUE self, VALUE rb_new_root)
145
145
  {
146
- xmlDocPtr doc;
147
- xmlNodePtr new_root;
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
- old_root = NULL;
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
- return root;
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
- Data_Get_Struct(root, xmlNode, new_root);
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
- /* If the new root's document is not the same as the current document,
169
- * then we need to dup the node in to this document. */
170
- if (new_root->doc != doc) {
171
- old_root = xmlDocGetRootElement(doc);
172
- if (!(new_root = xmlDocCopyNode(new_root, doc, 1))) {
173
- rb_raise(rb_eRuntimeError, "Could not reparent node (xmlDocCopyNode)");
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(doc, new_root);
178
- if (old_root) { noko_xml_document_pin_node(old_root); }
179
- return root;
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
- root(VALUE self)
188
+ rb_xml_document_root(VALUE self)
190
189
  {
191
- xmlDocPtr doc;
192
- xmlNodePtr root;
190
+ xmlDocPtr c_document;
191
+ xmlNodePtr c_root;
193
192
 
194
- Data_Get_Struct(self, xmlDoc, doc);
193
+ Data_Get_Struct(self, xmlDoc, c_document);
195
194
 
196
- root = xmlDocGetRootElement(doc);
195
+ c_root = xmlDocGetRootElement(c_document);
196
+ if (!c_root) {
197
+ return Qnil;
198
+ }
197
199
 
198
- if (!root) { return Qnil; }
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", root, 0);
670
- rb_define_method(cNokogiriXmlDocument, "root=", set_root, 1);
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);
@@ -2,7 +2,7 @@
2
2
 
3
3
  VALUE cNokogiriXmlNode ;
4
4
 
5
- static ID decorate, decorate_bang;
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, decorate_bang, 0);
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 klass, xmlNodePtr node)
1659
+ noko_xml_node_wrap(VALUE rb_class, xmlNodePtr c_node)
1659
1660
  {
1660
- VALUE document = Qnil ;
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 doc;
1663
+ xmlDocPtr c_doc;
1665
1664
  void (*mark_method)(xmlNodePtr) = NULL ;
1666
1665
 
1667
- assert(node);
1666
+ assert(c_node);
1668
1667
 
1669
- if (node->type == XML_DOCUMENT_NODE || node->type == XML_HTML_DOCUMENT_NODE) {
1670
- return DOC_RUBY_OBJECT(node->doc);
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
- doc = node->doc;
1677
- if (doc->type == XML_DOCUMENT_FRAG_NODE) { doc = doc->doc; }
1678
- node_has_a_document = DOC_RUBY_OBJECT_TEST(doc);
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 (node->_private && node_has_a_document) {
1681
- return (VALUE)node->_private;
1679
+ if (c_node->_private && node_has_a_document) {
1680
+ return (VALUE)c_node->_private;
1682
1681
  }
1683
1682
 
1684
- if (!RTEST(klass)) {
1685
- switch (node->type) {
1683
+ if (!RTEST(rb_class)) {
1684
+ switch (c_node->type) {
1686
1685
  case XML_ELEMENT_NODE:
1687
- klass = cNokogiriXmlElement;
1686
+ rb_class = cNokogiriXmlElement;
1688
1687
  break;
1689
1688
  case XML_TEXT_NODE:
1690
- klass = cNokogiriXmlText;
1689
+ rb_class = cNokogiriXmlText;
1691
1690
  break;
1692
1691
  case XML_ATTRIBUTE_NODE:
1693
- klass = cNokogiriXmlAttr;
1692
+ rb_class = cNokogiriXmlAttr;
1694
1693
  break;
1695
1694
  case XML_ENTITY_REF_NODE:
1696
- klass = cNokogiriXmlEntityReference;
1695
+ rb_class = cNokogiriXmlEntityReference;
1697
1696
  break;
1698
1697
  case XML_COMMENT_NODE:
1699
- klass = cNokogiriXmlComment;
1698
+ rb_class = cNokogiriXmlComment;
1700
1699
  break;
1701
1700
  case XML_DOCUMENT_FRAG_NODE:
1702
- klass = cNokogiriXmlDocumentFragment;
1701
+ rb_class = cNokogiriXmlDocumentFragment;
1703
1702
  break;
1704
1703
  case XML_PI_NODE:
1705
- klass = cNokogiriXmlProcessingInstruction;
1704
+ rb_class = cNokogiriXmlProcessingInstruction;
1706
1705
  break;
1707
1706
  case XML_ENTITY_DECL:
1708
- klass = cNokogiriXmlEntityDecl;
1707
+ rb_class = cNokogiriXmlEntityDecl;
1709
1708
  break;
1710
1709
  case XML_CDATA_SECTION_NODE:
1711
- klass = cNokogiriXmlCData;
1710
+ rb_class = cNokogiriXmlCData;
1712
1711
  break;
1713
1712
  case XML_DTD_NODE:
1714
- klass = cNokogiriXmlDtd;
1713
+ rb_class = cNokogiriXmlDtd;
1715
1714
  break;
1716
1715
  case XML_ATTRIBUTE_DECL:
1717
- klass = cNokogiriXmlAttributeDecl;
1716
+ rb_class = cNokogiriXmlAttributeDecl;
1718
1717
  break;
1719
1718
  case XML_ELEMENT_DECL:
1720
- klass = cNokogiriXmlElementDecl;
1719
+ rb_class = cNokogiriXmlElementDecl;
1721
1720
  break;
1722
1721
  default:
1723
- klass = cNokogiriXmlNode;
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(klass, mark_method, debug_node_dealloc, node) ;
1730
- node->_private = (void *)rb_node;
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
- document = DOC_RUBY_OBJECT(doc);
1734
- node_cache = DOC_NODE_CACHE(doc);
1735
- rb_ary_push(node_cache, rb_node);
1736
- rb_funcall(document, decorate, 1, rb_node);
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
- decorate = rb_intern("decorate");
1822
- decorate_bang = rb_intern("decorate!");
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Nokogiri
3
3
  # The version of Nokogiri you are using
4
- VERSION = "1.11.2"
4
+ VERSION = "1.11.3"
5
5
  end
@@ -14,11 +14,12 @@ module Nokogiri
14
14
  # Nokogiri::XML::Searchable#xpath
15
15
  #
16
16
  class Document < Nokogiri::XML::Node
17
- # I'm ignoring unicode characters here.
18
- # See http://www.w3.org/TR/REC-xml-names/#ns-decl for more details.
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 + "\\-.0-9"
21
- NCNAME_RE = /^xmlns(:[#{NCNAME_START_CHAR}][#{NCNAME_CHAR}]*)?$/
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 an element with +name+, and optionally setting the content and attributes.
122
+ # Create a new +Element+ with +name+ sharing GC lifecycle with the document, optionally
123
+ # setting contents or attributes.
122
124
  #
123
- # doc.create_element "div" # <div></div>
124
- # doc.create_element "div", :class => "container" # <div class='container'></div>
125
- # doc.create_element "div", "contents" # <div>contents</div>
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
- def create_element name, *args, &block
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
- args.each do |arg|
157
+ contents_or_attrs.each do |arg|
132
158
  case arg
133
159
  when Hash
134
- arg.each { |k,v|
160
+ arg.each do |k, v|
135
161
  key = k.to_s
136
162
  if key =~ NCNAME_RE
137
- ns_name = key.split(":", 2)[1]
138
- elm.add_namespace_definition ns_name, v
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? or n.prefix == '' }
173
+ if ns = elm.namespace_definitions.find { |n| n.prefix.nil? || (n.prefix == '') }
148
174
  elm.namespace = ns
149
175
  end
150
176
  elm
@@ -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.2
4
+ version: 1.11.3
5
5
  platform: x86-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-03-11 00:00:00.000000000 Z
20
+ date: 2021-04-07 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: racc