nokogiri 1.13.7-x86_64-darwin → 1.13.8-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 492740d1c561571093b8473a1f74428900eee7f2b3720aaf07d595a463a6e36c
4
- data.tar.gz: 827ed12e80e7616e1d03049bb2d1fb92668aaedffb4767790cb83c0476b7ab7e
3
+ metadata.gz: 886fee59b4efd6b21f1cc2fe394bd6231d1a1911af74a59bbda6ce02802e6ff5
4
+ data.tar.gz: 1a680ad4110a7ef5d93c055260234c23cd10415efcea54294789f90a8d25c5f4
5
5
  SHA512:
6
- metadata.gz: a76dd27333f5b2c55d599c8c4894770b7b41d9c87c587a569d89d05dc9c8b3523d3de9ec059405928adc30154eee58c6e3432b110b3c5c92ac44658170a39a43
7
- data.tar.gz: 5c4309cb9fc79f6e858b61b1729b2b9681a5af948b2cffb873439dc63058b2cbd8f56d79c5528c8f607f52beb19d9a3cbd8155b98cd872684c5ad8bcd4114efc
6
+ metadata.gz: 304d4f8f17fac5d2d0ee90c10402f01a0ec14145758d5161d0aa3f2ccfb9fc3656c2ec23bfac9c6ddc4794827b66ecf573ea7bd75982c63714e4d424dff9a759
7
+ data.tar.gz: e437fe17297bcfcf27aaa8200cf687b5776c1704cc7fc3d4c83dfdc27dbf63f7009cc14acbcef0ed15969ede43bd87f0040b596f12995576cc35a73e607f5e64
@@ -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);
Binary file
Binary file
Binary file
Binary file
@@ -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: x86_64-darwin
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: racc