nokogiri 1.13.7 → 1.13.8

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: 4d0977b7ea9d955b38bbbe01bac11db8ffae4b6cc95cd7d95f38c337050ab1cf
4
- data.tar.gz: 458389173207030d4817b7e220cc42503c847b9d01994885d750742b033603a0
3
+ metadata.gz: 57a1be1596b77f21f907091ed4f729cc99bd4807cc8a116fdb2c705ff7be634c
4
+ data.tar.gz: e885178e15ae558183b813476584f96c2723a5176e9bbc0d1afcdd94e7c5b02d
5
5
  SHA512:
6
- metadata.gz: d8fe3ea940995f44719f4e0e2b47cbf88708224f0e1791c760dd31dac37dcc5fa859c78f87c942934074ad9490e4c323d7dea034d87a8b46813ab707d0caaa6c
7
- data.tar.gz: d98a398a9594b7266cd41b96b505cdeef67de286a3a6d8615657c59a67b0c36d175ed9d4649f6e93c00ecef67804e1c6d6f1f96fe7fb177ea571e9365448bc18
6
+ metadata.gz: 7b46507c07b2eb1e1747ea33a450cf28ebe719966bc394a1a0a25d348b189168cd8c4c75dbe0405dd1f40d386096468119492b96ddd6322a2ce02228a7e62ceb
7
+ data.tar.gz: ea9338bde47956061977946250aa4d687cc1e526b99ced6f4413d1a57442390e133646cc0b8c9b7c9f169ecb96695873e4221b07803230dab1fe68420f6650eb
@@ -974,6 +974,7 @@ have_func("xmlRelaxNGSetValidStructuredErrors") # introduced in libxml 2.6.21
974
974
  have_func("xmlSchemaSetValidStructuredErrors") # introduced in libxml 2.6.23
975
975
  have_func("xmlSchemaSetParserStructuredErrors") # introduced in libxml 2.6.23
976
976
  have_func("rb_gc_location") # introduced in Ruby 2.7
977
+ have_func("rb_category_warning") # introduced in Ruby 3.0
977
978
 
978
979
  have_func("vasprintf")
979
980
 
@@ -202,6 +202,12 @@ NOKOPUBFUN VALUE Nokogiri_wrap_xml_document(VALUE klass,
202
202
  #define DISCARD_CONST_QUAL(t, v) ((t)(uintptr_t)(v))
203
203
  #define DISCARD_CONST_QUAL_XMLCHAR(v) DISCARD_CONST_QUAL(xmlChar *, v)
204
204
 
205
+ #if HAVE_RB_CATEGORY_WARNING
206
+ # define NOKO_WARN_DEPRECATION(message) rb_category_warning(RB_WARN_CATEGORY_DEPRECATED, message)
207
+ #else
208
+ # define NOKO_WARN_DEPRECATION(message) rb_warning(message)
209
+ #endif
210
+
205
211
  void Nokogiri_structured_error_func_save(libxmlStructuredErrorHandlerState *handler_state);
206
212
  void Nokogiri_structured_error_func_save_and_set(libxmlStructuredErrorHandlerState *handler_state, void *user_data,
207
213
  xmlStructuredErrorFunc handler);
@@ -1806,7 +1806,7 @@ rb_xml_node_new(int argc, VALUE *argv, VALUE klass)
1806
1806
  }
1807
1807
  if (!rb_obj_is_kind_of(rb_document_node, cNokogiriXmlDocument)) {
1808
1808
  // TODO: deprecate allowing Node
1809
- rb_warn("Passing a Node as the second parameter to Node.new is deprecated. Please pass a Document instead, or prefer an alternative constructor like Node#add_child. This will become an error in a future release of Nokogiri.");
1809
+ NOKO_WARN_DEPRECATION("Passing a Node as the second parameter to Node.new is deprecated. Please pass a Document instead, or prefer an alternative constructor like Node#add_child. This will become an error in a future release of Nokogiri.");
1810
1810
  }
1811
1811
  Noko_Node_Get_Struct(rb_document_node, xmlNode, c_document_node);
1812
1812
 
@@ -31,6 +31,7 @@ has_attributes(xmlTextReaderPtr reader)
31
31
  return (0);
32
32
  }
33
33
 
34
+ // TODO: merge this function into the `namespaces` method implementation
34
35
  static void
35
36
  Nokogiri_xml_node_namespaces(xmlNodePtr node, VALUE attr_hash)
36
37
  {
@@ -150,7 +151,11 @@ namespaces(VALUE self)
150
151
  /*
151
152
  :call-seq: attribute_nodes() → Array<Nokogiri::XML::Attr>
152
153
 
153
- Get the attributes of the current node as an Array of Attr
154
+ Get the attributes of the current node as an Array of XML:Attr
155
+
156
+ ⚠ This method is deprecated and unsafe to use. It will be removed in a future version of Nokogiri.
157
+
158
+ See related: #attribute_hash, #attributes
154
159
  */
155
160
  static VALUE
156
161
  rb_xml_reader_attribute_nodes(VALUE rb_reader)
@@ -160,6 +165,10 @@ rb_xml_reader_attribute_nodes(VALUE rb_reader)
160
165
  VALUE attr_nodes;
161
166
  int j;
162
167
 
168
+ // TODO: deprecated, remove in Nokogiri v1.15, see https://github.com/sparklemotion/nokogiri/issues/2598
169
+ // After removal, we can also remove all the "node_has_a_document" special handling from xml_node.c
170
+ NOKO_WARN_DEPRECATION("Reader#attribute_nodes is deprecated and will be removed in a future version of Nokogiri. Please use Reader#attribute_hash instead.");
171
+
163
172
  Data_Get_Struct(rb_reader, xmlTextReader, c_reader);
164
173
 
165
174
  if (! has_attributes(c_reader)) {
@@ -181,6 +190,47 @@ rb_xml_reader_attribute_nodes(VALUE rb_reader)
181
190
  return attr_nodes;
182
191
  }
183
192
 
193
+ /*
194
+ :call-seq: attribute_hash() → Hash<String ⇒ String>
195
+
196
+ Get the attributes of the current node as a Hash of names and values.
197
+
198
+ See related: #attributes and #namespaces
199
+ */
200
+ static VALUE
201
+ rb_xml_reader_attribute_hash(VALUE rb_reader)
202
+ {
203
+ VALUE rb_attributes = rb_hash_new();
204
+ xmlTextReaderPtr c_reader;
205
+ xmlNodePtr c_node;
206
+ xmlAttrPtr c_property;
207
+
208
+ Data_Get_Struct(rb_reader, xmlTextReader, c_reader);
209
+
210
+ if (!has_attributes(c_reader)) {
211
+ return rb_attributes;
212
+ }
213
+
214
+ c_node = xmlTextReaderExpand(c_reader);
215
+ c_property = c_node->properties;
216
+ while (c_property != NULL) {
217
+ VALUE rb_name = NOKOGIRI_STR_NEW2(c_property->name);
218
+ VALUE rb_value = Qnil;
219
+ xmlChar *c_value = xmlNodeGetContent((xmlNode *)c_property);
220
+
221
+ if (c_value) {
222
+ rb_value = NOKOGIRI_STR_NEW2(c_value);
223
+ xmlFree(c_value);
224
+ }
225
+
226
+ rb_hash_aset(rb_attributes, rb_name, rb_value);
227
+
228
+ c_property = c_property->next;
229
+ }
230
+
231
+ return rb_attributes;
232
+ }
233
+
184
234
  /*
185
235
  * call-seq:
186
236
  * attribute_at(index)
@@ -696,6 +746,7 @@ noko_init_xml_reader()
696
746
  rb_define_method(cNokogiriXmlReader, "attribute_at", attribute_at, 1);
697
747
  rb_define_method(cNokogiriXmlReader, "attribute_count", attribute_count, 0);
698
748
  rb_define_method(cNokogiriXmlReader, "attribute_nodes", rb_xml_reader_attribute_nodes, 0);
749
+ rb_define_method(cNokogiriXmlReader, "attribute_hash", rb_xml_reader_attribute_hash, 0);
699
750
  rb_define_method(cNokogiriXmlReader, "attributes?", attributes_eh, 0);
700
751
  rb_define_method(cNokogiriXmlReader, "base_uri", rb_xml_reader_base_uri, 0);
701
752
  rb_define_method(cNokogiriXmlReader, "default?", default_eh, 0);
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Nokogiri
4
4
  # The version of Nokogiri you are using
5
- VERSION = "1.13.7"
5
+ VERSION = "1.13.8"
6
6
  end
@@ -83,16 +83,14 @@ module Nokogiri
83
83
  end
84
84
  private :initialize
85
85
 
86
- # Get the attributes of the current node as a Hash
86
+ # Get the attributes and namespaces of the current node as a Hash.
87
87
  #
88
- # [Returns] (Hash<String, String>) Attribute names and values
88
+ # This is the union of Reader#attribute_hash and Reader#namespaces
89
+ #
90
+ # [Returns]
91
+ # (Hash<String, String>) Attribute names and values, and namespace prefixes and hrefs.
89
92
  def attributes
90
- attrs_hash = attribute_nodes.each_with_object({}) do |node, hash|
91
- hash[node.name] = node.to_s
92
- end
93
- ns = namespaces
94
- attrs_hash.merge!(ns) if ns
95
- attrs_hash
93
+ attribute_hash.merge(namespaces)
96
94
  end
97
95
 
98
96
  ###
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.13.7
4
+ version: 1.13.8
5
5
  platform: ruby
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: 2022-07-12 00:00:00.000000000 Z
23
+ date: 2022-07-23 00:00:00.000000000 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mini_portile2