nokogiri 1.13.7 → 1.13.9

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: ae3b5f6cb32585ea5caf7fdc4119cdbfb9fb2c1ef338e732a1a7e199a24a7eea
4
+ data.tar.gz: f95707623e5201074c68d49fb5cbaed6f15d8fd6c73e6a0f5cd3995da1c366ab
5
5
  SHA512:
6
- metadata.gz: d8fe3ea940995f44719f4e0e2b47cbf88708224f0e1791c760dd31dac37dcc5fa859c78f87c942934074ad9490e4c323d7dea034d87a8b46813ab707d0caaa6c
7
- data.tar.gz: d98a398a9594b7266cd41b96b505cdeef67de286a3a6d8615657c59a67b0c36d175ed9d4649f6e93c00ecef67804e1c6d6f1f96fe7fb177ea571e9365448bc18
6
+ metadata.gz: 0e2c6b7c3f537da076a47da4e53fb9e2aed0658f9342f6e5de307938d525cd24942cef46ee7f500c144b50d1379ddae669586ff83552ae604f1131955566d572
7
+ data.tar.gz: ef3f5af7bc323c13f4319703363ed6100aa9077fab48e34b2c6e3456b8d4a6d1587a222ac025ee8c714c9262557c820b7df2d1f9f264148f742e7a182b64e1d4
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:
@@ -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
 
@@ -171,6 +171,7 @@ int noko_io_write(void *ctx, char *buffer, int len);
171
171
  int noko_io_close(void *ctx);
172
172
 
173
173
  #define Noko_Node_Get_Struct(obj,type,sval) ((sval) = (type*)DATA_PTR(obj))
174
+ #define Noko_Namespace_Get_Struct(obj,type,sval) ((sval) = (type*)DATA_PTR(obj))
174
175
 
175
176
  VALUE noko_xml_node_wrap(VALUE klass, xmlNodePtr node) ;
176
177
  VALUE noko_xml_node_wrap_node_set_result(xmlNodePtr node, VALUE node_set) ;
@@ -202,6 +203,12 @@ NOKOPUBFUN VALUE Nokogiri_wrap_xml_document(VALUE klass,
202
203
  #define DISCARD_CONST_QUAL(t, v) ((t)(uintptr_t)(v))
203
204
  #define DISCARD_CONST_QUAL_XMLCHAR(v) DISCARD_CONST_QUAL(xmlChar *, v)
204
205
 
206
+ #if HAVE_RB_CATEGORY_WARNING
207
+ # define NOKO_WARN_DEPRECATION(message) rb_category_warning(RB_WARN_CATEGORY_DEPRECATED, message)
208
+ #else
209
+ # define NOKO_WARN_DEPRECATION(message) rb_warning(message)
210
+ #endif
211
+
205
212
  void Nokogiri_structured_error_func_save(libxmlStructuredErrorHandlerState *handler_state);
206
213
  void Nokogiri_structured_error_func_save_and_set(libxmlStructuredErrorHandlerState *handler_state, void *user_data,
207
214
  xmlStructuredErrorFunc handler);
@@ -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;
@@ -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: 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-10-18 00:00:00.000000000 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mini_portile2
@@ -487,14 +487,11 @@ files:
487
487
  - patches/libxml2/0001-Remove-script-macro-support.patch
488
488
  - patches/libxml2/0002-Update-entities-to-remove-handling-of-ssi.patch
489
489
  - patches/libxml2/0003-libxml2.la-is-in-top_builddir.patch
490
- - patches/libxml2/0004-use-glibc-strlen.patch
491
490
  - patches/libxml2/0005-avoid-isnan-isinf.patch
492
- - patches/libxml2/0006-update-automake-files-for-arm64.patch
493
- - patches/libxml2/0008-htmlParseComment-handle-abruptly-closed-comments.patch
494
491
  - patches/libxml2/0009-allow-wildcard-namespaces.patch
495
492
  - patches/libxslt/0001-update-automake-files-for-arm64.patch
496
- - ports/archives/libxml2-2.9.14.tar.xz
497
- - ports/archives/libxslt-1.1.35.tar.xz
493
+ - ports/archives/libxml2-2.10.3.tar.xz
494
+ - ports/archives/libxslt-1.1.37.tar.xz
498
495
  homepage: https://nokogiri.org
499
496
  licenses:
500
497
  - MIT
@@ -1,53 +0,0 @@
1
- From c94172d2a4451368530db2186190d70be8a1d9e5 Mon Sep 17 00:00:00 2001
2
- From: Ilya Zub <ilya@serpapi.com>
3
- Date: Wed, 23 Dec 2020 12:45:29 +0200
4
- Subject: Use glibc strlen to speed up xmlStrlen
5
- MIME-Version: 1.0
6
- Content-Type: text/plain; charset=UTF-8
7
- Content-Transfer-Encoding: 8bit
8
-
9
- xmlStrlen (entire HTML file): 926171.936981 μs
10
- glibc_xmlStrlen (entire HTML file): 36905.903992 μs
11
- delta (xmlStrlen ÷ glibc_xmlStrlen): 25.094584 times
12
-
13
- xmlStrlen (average string): 57479.204010 μs
14
- glibc_xmlStrlen (average string): 5802.069000 μs
15
- delta (xmlStrlen ÷ glibc_xmlStrlen): 9.905937 times
16
-
17
- xmlStrlen (bigger string): 388056.315979 μs
18
- glibc_xmlStrlen (bigger string): 12797.856995 μs
19
- delta (xmlStrlen ÷ glibc_xmlStrlen): 30.318382 times
20
-
21
- xmlStrlen (smallest string): 15870.046021 μs
22
- glibc_xmlStrlen (smallest string): 6282.208984 μs
23
- delta (xmlStrlen ÷ glibc_xmlStrlen): 2.527903 times
24
-
25
- See https://gitlab.gnome.org/GNOME/libxml2/-/issues/212 for reference.
26
- ---
27
- xmlstring.c | 9 ++-------
28
- 1 file changed, 2 insertions(+), 7 deletions(-)
29
-
30
- diff --git a/xmlstring.c b/xmlstring.c
31
- index e8a1e45d..df247dff 100644
32
- --- a/xmlstring.c
33
- +++ b/xmlstring.c
34
- @@ -423,12 +423,7 @@ xmlStrsub(const xmlChar *str, int start, int len) {
35
-
36
- int
37
- xmlStrlen(const xmlChar *str) {
38
- - size_t len = 0;
39
- -
40
- if (str == NULL) return(0);
41
- - while (*str != 0) { /* non input consuming */
42
- - str++;
43
- - len++;
44
- - }
45
- - return(len > INT_MAX ? 0 : len);
46
- +
47
- + return strlen((const char*)str);
48
- }
49
-
50
- /**
51
- --
52
- 2.29.2
53
-