nokogiri 1.13.7-java → 1.13.9-java

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: b2c2dcc754eb67e61eaf8bf2c3b3c0d86af96dbda9137ca6c593ea18fbfa51a8
4
- data.tar.gz: e3c13e63d1cbc2825ea1ddf1f1edab38b5435b09866d5934217d311b82bf5642
3
+ metadata.gz: 2f30a64388fd65fe676b77a7c2ce550226b12ece1d7c8498c2fefb7b035beb2c
4
+ data.tar.gz: 9fb465b982130a628d134758cc147d5e66cf107a6315452fec01e8a2e854806a
5
5
  SHA512:
6
- metadata.gz: e94c8990874bea3e893843642a295c983254ccb6fcdd3278d1681714fd42c8b96d1b3633b7c12897bbb4f3b3d2ca6c4066358ce270b08c521b75c8c834aa38d5
7
- data.tar.gz: 6b4b60e9cb6c5334a69414cbb65cfe02b9017fd28953c59b7e675291d67e6ab2d356f0ecfd6692ca44a6ce1fc85f16eb00bd1f523d88ac05e8b6a0c27d7c2026
6
+ metadata.gz: 7639c14bc8c475ddff4dce625e080ace25e36111bcbad8f2f02671cb4d8d339ee848b5ed362ae4d5ce6a2a75082036bb2b4ce447dd4cbf506bed6a0c1144cdab
7
+ data.tar.gz: 1972ce89fd6f61a78d2cf14072f01313cd6a849330dd4d5bc1c80bd2d9c57400681a225aa1a1f0092efd9a265fd97cc4b52c04bd47fb79ee0b3ff63a98cd0918
data/dependencies.yml CHANGED
@@ -1,16 +1,16 @@
1
1
  libxml2:
2
- version: "2.9.14"
3
- sha256: "60d74a257d1ccec0475e749cba2f21559e48139efba6ff28224357c7c798dfee"
4
- # sha-256 hash provided in https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.14.sha256sum
2
+ version: "2.10.3"
3
+ sha256: "5d2cc3d78bec3dbe212a9d7fa629ada25a7da928af432c93060ff5c17ee28a9c"
4
+ # sha-256 hash provided in https://download.gnome.org/sources/libxml2/2.10/libxml2-2.10.3.sha256sum
5
5
 
6
6
  libxslt:
7
- version: "1.1.35"
8
- sha256: "8247f33e9a872c6ac859aa45018bc4c4d00b97e2feac9eebc10c93ce1f34dd79"
9
- # sha-256 hash provided in https://download.gnome.org/sources/libxslt/1.1/libxslt-1.1.35.sha256sum
7
+ version: "1.1.37"
8
+ sha256: "3a4b27dc8027ccd6146725950336f1ec520928f320f144eb5fa7990ae6123ab4"
9
+ # sha-256 hash provided in https://download.gnome.org/sources/libxslt/1.1/libxslt-1.1.37.sha256sum
10
10
 
11
11
  zlib:
12
- version: "1.2.12"
13
- sha256: "91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9"
12
+ version: "1.2.13"
13
+ sha256: "b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30"
14
14
  # SHA-256 hash provided on http://zlib.net/
15
15
 
16
16
  libiconv:
@@ -141,9 +141,17 @@ public class XmlReader extends RubyObject
141
141
  public IRubyObject
142
142
  attribute_nodes(ThreadContext context)
143
143
  {
144
+ context.runtime.getWarnings().warn("Reader#attribute_nodes is deprecated and will be removed in a future version of Nokogiri. Please use Reader#attribute_hash instead.");
144
145
  return currentNode().getAttributesNodes();
145
146
  }
146
147
 
148
+ @JRubyMethod
149
+ public IRubyObject
150
+ attribute_hash(ThreadContext context)
151
+ {
152
+ return currentNode().getAttributes(context);
153
+ }
154
+
147
155
  @JRubyMethod(name = "attributes?")
148
156
  public IRubyObject
149
157
  attributes_p(ThreadContext context)
@@ -112,9 +112,10 @@ public abstract class ReaderNode
112
112
  getAttributes(ThreadContext context)
113
113
  {
114
114
  final Ruby runtime = context.runtime;
115
- if (attributeList == null) { return runtime.getNil(); }
116
115
  RubyHash hash = RubyHash.newHash(runtime);
116
+ if (attributeList == null) { return hash; }
117
117
  for (int i = 0; i < attributeList.length; i++) {
118
+ if (isNamespace(attributeList.names.get(i))) { continue; }
118
119
  IRubyObject k = stringOrBlank(runtime, attributeList.names.get(i));
119
120
  IRubyObject v = stringOrBlank(runtime, attributeList.values.get(i));
120
121
  hash.fastASetCheckString(runtime, k, v); // hash.op_aset(context, k, v)
@@ -150,8 +151,8 @@ public abstract class ReaderNode
150
151
  getNamespaces(ThreadContext context)
151
152
  {
152
153
  final Ruby runtime = context.runtime;
153
- if (namespaces == null) { return runtime.getNil(); }
154
154
  RubyHash hash = RubyHash.newHash(runtime);
155
+ if (namespaces == null) { return hash; }
155
156
  for (Map.Entry<String, String> entry : namespaces.entrySet()) {
156
157
  IRubyObject k = stringOrBlank(runtime, entry.getKey());
157
158
  IRubyObject v = stringOrBlank(runtime, entry.getValue());
@@ -712,9 +712,17 @@ else
712
712
  else
713
713
  class << recipe
714
714
  def configure
715
- cflags = concat_flags(ENV["CFLAGS"], "-fPIC", "-g")
716
- execute("configure",
717
- ["env", "CHOST=#{host}", "CFLAGS=#{cflags}", "./configure", "--static", configure_prefix])
715
+ env = {}
716
+ env["CFLAGS"] = concat_flags(ENV["CFLAGS"], "-fPIC", "-g")
717
+ env["CHOST"] = host
718
+ execute("configure", ["./configure", "--static", configure_prefix], { env: env })
719
+ if darwin?
720
+ # needed as of zlib 1.2.13
721
+ Dir.chdir(work_path) do
722
+ makefile = File.read("Makefile").gsub(/^AR=.*$/, "AR=#{host}-libtool")
723
+ File.open("Makefile", "w") { |m| m.write(makefile) }
724
+ end
725
+ end
718
726
  end
719
727
  end
720
728
  end
@@ -839,6 +847,11 @@ else
839
847
  recipe.configure_options += ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"]
840
848
  end
841
849
 
850
+ if windows?
851
+ cflags = concat_flags(cflags, "-ULIBXSLT_STATIC", "-DIN_LIBXSLT")
852
+ cflags = concat_flags(cflags, "-ULIBEXSLT_STATIC", "-DIN_LIBEXSLT")
853
+ end
854
+
842
855
  recipe.configure_options << if source_dir
843
856
  "--config-cache"
844
857
  else
@@ -974,6 +987,7 @@ have_func("xmlRelaxNGSetValidStructuredErrors") # introduced in libxml 2.6.21
974
987
  have_func("xmlSchemaSetValidStructuredErrors") # introduced in libxml 2.6.23
975
988
  have_func("xmlSchemaSetParserStructuredErrors") # introduced in libxml 2.6.23
976
989
  have_func("rb_gc_location") # introduced in Ruby 2.7
990
+ have_func("rb_category_warning") # introduced in Ruby 3.0
977
991
 
978
992
  have_func("vasprintf")
979
993
 
@@ -104,7 +104,11 @@ recursively_remove_namespaces_from_node(xmlNodePtr node)
104
104
  (node->type == XML_XINCLUDE_START) ||
105
105
  (node->type == XML_XINCLUDE_END)) &&
106
106
  node->nsDef) {
107
- xmlFreeNsList(node->nsDef);
107
+ xmlNsPtr curr = node->nsDef;
108
+ while (curr) {
109
+ noko_xml_document_pin_namespace(curr, node->doc);
110
+ curr = curr->next;
111
+ }
108
112
  node->nsDef = NULL;
109
113
  }
110
114
 
@@ -25,13 +25,15 @@
25
25
  VALUE cNokogiriXmlNamespace ;
26
26
 
27
27
  static void
28
- dealloc_namespace(xmlNsPtr ns)
28
+ _xml_namespace_dealloc(void *ptr)
29
29
  {
30
30
  /*
31
31
  * this deallocator is only used for namespace nodes that are part of an xpath
32
32
  * node set. see noko_xml_namespace_wrap().
33
33
  */
34
+ xmlNsPtr ns = ptr;
34
35
  NOKOGIRI_DEBUG_START(ns) ;
36
+
35
37
  if (ns->href) {
36
38
  xmlFree(DISCARD_CONST_QUAL_XMLCHAR(ns->href));
37
39
  }
@@ -42,6 +44,36 @@ dealloc_namespace(xmlNsPtr ns)
42
44
  NOKOGIRI_DEBUG_END(ns) ;
43
45
  }
44
46
 
47
+ #ifdef HAVE_RB_GC_LOCATION
48
+ static void
49
+ _xml_namespace_update_references(void *ptr)
50
+ {
51
+ xmlNsPtr ns = ptr;
52
+ if (ns->_private) {
53
+ ns->_private = (void *)rb_gc_location((VALUE)ns->_private);
54
+ }
55
+ }
56
+ #else
57
+ # define _xml_namespace_update_references 0
58
+ #endif
59
+
60
+ static const rb_data_type_t nokogiri_xml_namespace_type_with_dealloc = {
61
+ "Nokogiri/XMLNamespace/WithDealloc",
62
+ {0, _xml_namespace_dealloc, 0, _xml_namespace_update_references},
63
+ 0, 0,
64
+ #ifdef RUBY_TYPED_FREE_IMMEDIATELY
65
+ RUBY_TYPED_FREE_IMMEDIATELY,
66
+ #endif
67
+ };
68
+
69
+ static const rb_data_type_t nokogiri_xml_namespace_type_without_dealloc = {
70
+ "Nokogiri/XMLNamespace/WithoutDealloc",
71
+ {0, 0, 0, _xml_namespace_update_references},
72
+ 0, 0,
73
+ #ifdef RUBY_TYPED_FREE_IMMEDIATELY
74
+ RUBY_TYPED_FREE_IMMEDIATELY,
75
+ #endif
76
+ };
45
77
 
46
78
  /*
47
79
  * call-seq:
@@ -54,7 +86,7 @@ prefix(VALUE self)
54
86
  {
55
87
  xmlNsPtr ns;
56
88
 
57
- Data_Get_Struct(self, xmlNs, ns);
89
+ Noko_Namespace_Get_Struct(self, xmlNs, ns);
58
90
  if (!ns->prefix) { return Qnil; }
59
91
 
60
92
  return NOKOGIRI_STR_NEW2(ns->prefix);
@@ -71,7 +103,7 @@ href(VALUE self)
71
103
  {
72
104
  xmlNsPtr ns;
73
105
 
74
- Data_Get_Struct(self, xmlNs, ns);
106
+ Noko_Namespace_Get_Struct(self, xmlNs, ns);
75
107
  if (!ns->href) { return Qnil; }
76
108
 
77
109
  return NOKOGIRI_STR_NEW2(ns->href);
@@ -87,14 +119,18 @@ noko_xml_namespace_wrap(xmlNsPtr c_namespace, xmlDocPtr c_document)
87
119
  }
88
120
 
89
121
  if (c_document) {
90
- rb_namespace = Data_Wrap_Struct(cNokogiriXmlNamespace, 0, 0, c_namespace);
122
+ rb_namespace = TypedData_Wrap_Struct(cNokogiriXmlNamespace,
123
+ &nokogiri_xml_namespace_type_without_dealloc,
124
+ c_namespace);
91
125
 
92
126
  if (DOC_RUBY_OBJECT_TEST(c_document)) {
93
127
  rb_iv_set(rb_namespace, "@document", DOC_RUBY_OBJECT(c_document));
94
128
  rb_ary_push(DOC_NODE_CACHE(c_document), rb_namespace);
95
129
  }
96
130
  } else {
97
- rb_namespace = Data_Wrap_Struct(cNokogiriXmlNamespace, 0, dealloc_namespace, c_namespace);
131
+ rb_namespace = TypedData_Wrap_Struct(cNokogiriXmlNamespace,
132
+ &nokogiri_xml_namespace_type_with_dealloc,
133
+ c_namespace);
98
134
  }
99
135
 
100
136
  c_namespace->_private = (void *)rb_namespace;
@@ -1353,7 +1353,7 @@ set_namespace(VALUE self, VALUE namespace)
1353
1353
  Noko_Node_Get_Struct(self, xmlNode, node);
1354
1354
 
1355
1355
  if (!NIL_P(namespace)) {
1356
- Data_Get_Struct(namespace, xmlNs, ns);
1356
+ Noko_Namespace_Get_Struct(namespace, xmlNs, ns);
1357
1357
  }
1358
1358
 
1359
1359
  xmlSetNs(node, ns);
@@ -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);
@@ -373,7 +373,10 @@ new (VALUE klass, VALUE nodeobj)
373
373
 
374
374
  Noko_Node_Get_Struct(nodeobj, xmlNode, node);
375
375
 
376
+ #if LIBXML_VERSION < 21000
377
+ /* deprecated in 40483d0 */
376
378
  xmlXPathInit();
379
+ #endif
377
380
 
378
381
  ctx = xmlXPathNewContext(node->doc);
379
382
  ctx->node = node;
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.9"
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.9
5
5
  platform: java
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-10-18 00:00:00.000000000 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  requirement: !ruby/object:Gem::Requirement