nokogiri 1.13.6 → 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: 111da6f69d040f9ac5c3573b0e03cdc5e09fb27c5d8ae8bc6e0bf70079dbcdb8
4
- data.tar.gz: ccbda476379e696103cf61983df914c6b7312090b5905daccb3077f0a25e60ba
3
+ metadata.gz: ae3b5f6cb32585ea5caf7fdc4119cdbfb9fb2c1ef338e732a1a7e199a24a7eea
4
+ data.tar.gz: f95707623e5201074c68d49fb5cbaed6f15d8fd6c73e6a0f5cd3995da1c366ab
5
5
  SHA512:
6
- metadata.gz: bbf69d93304d43cf38667fe66e84caf84b8ca4b89a3ec3d8139fe2f986c10bc5b971d4ed97870601be2ed92b6e748593fea02b89e7f6e2deed09c5a604d2d101
7
- data.tar.gz: 4a2a6b55fd87f8b4adb5e8687959d9f0c88334638ca2746761155b0214095ce14d648482833b8f80a59b94a54d29e26d9cae4caacda57b772fe00804de6cdabe
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
@@ -973,6 +986,8 @@ have_func("xmlRelaxNGSetParserStructuredErrors") # introduced in libxml 2.6.24
973
986
  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
989
+ have_func("rb_gc_location") # introduced in Ruby 2.7
990
+ have_func("rb_category_warning") # introduced in Ruby 3.0
976
991
 
977
992
  have_func("vasprintf")
978
993
 
data/ext/nokogiri/gumbo.c CHANGED
@@ -401,7 +401,7 @@ static xmlNodePtr
401
401
  extract_xml_node(VALUE node)
402
402
  {
403
403
  xmlNodePtr xml_node;
404
- Data_Get_Struct(node, xmlNode, xml_node);
404
+ Noko_Node_Get_Struct(node, xmlNode, xml_node);
405
405
  return xml_node;
406
406
  }
407
407
 
@@ -170,6 +170,9 @@ int noko_io_read(void *ctx, char *buffer, int len);
170
170
  int noko_io_write(void *ctx, char *buffer, int len);
171
171
  int noko_io_close(void *ctx);
172
172
 
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))
175
+
173
176
  VALUE noko_xml_node_wrap(VALUE klass, xmlNodePtr node) ;
174
177
  VALUE noko_xml_node_wrap_node_set_result(xmlNodePtr node, VALUE node_set) ;
175
178
  VALUE noko_xml_node_attrs(xmlNodePtr node) ;
@@ -200,6 +203,12 @@ NOKOPUBFUN VALUE Nokogiri_wrap_xml_document(VALUE klass,
200
203
  #define DISCARD_CONST_QUAL(t, v) ((t)(uintptr_t)(v))
201
204
  #define DISCARD_CONST_QUAL_XMLCHAR(v) DISCARD_CONST_QUAL(xmlChar *, v)
202
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
+
203
212
  void Nokogiri_structured_error_func_save(libxmlStructuredErrorHandlerState *handler_state);
204
213
  void Nokogiri_structured_error_func_save_and_set(libxmlStructuredErrorHandlerState *handler_state, void *user_data,
205
214
  xmlStructuredErrorFunc handler);
@@ -16,7 +16,7 @@ set_value(VALUE self, VALUE content)
16
16
  xmlChar *value;
17
17
  xmlNode *cur;
18
18
 
19
- Data_Get_Struct(self, xmlAttr, attr);
19
+ Noko_Node_Get_Struct(self, xmlAttr, attr);
20
20
 
21
21
  if (attr->children) {
22
22
  xmlFreeNodeList(attr->children);
@@ -68,7 +68,7 @@ new (int argc, VALUE *argv, VALUE klass)
68
68
  rb_raise(rb_eArgError, "parameter must be a Nokogiri::XML::Document");
69
69
  }
70
70
 
71
- Data_Get_Struct(document, xmlDoc, xml_doc);
71
+ Noko_Node_Get_Struct(document, xmlDoc, xml_doc);
72
72
 
73
73
  node = xmlNewDocProp(
74
74
  xml_doc,
@@ -12,7 +12,7 @@ static VALUE
12
12
  attribute_type(VALUE self)
13
13
  {
14
14
  xmlAttributePtr node;
15
- Data_Get_Struct(self, xmlAttribute, node);
15
+ Noko_Node_Get_Struct(self, xmlAttribute, node);
16
16
  return INT2NUM((long)node->atype);
17
17
  }
18
18
 
@@ -26,7 +26,7 @@ static VALUE
26
26
  default_value(VALUE self)
27
27
  {
28
28
  xmlAttributePtr node;
29
- Data_Get_Struct(self, xmlAttribute, node);
29
+ Noko_Node_Get_Struct(self, xmlAttribute, node);
30
30
 
31
31
  if (node->defaultValue) { return NOKOGIRI_STR_NEW2(node->defaultValue); }
32
32
  return Qnil;
@@ -45,7 +45,7 @@ enumeration(VALUE self)
45
45
  xmlEnumerationPtr enm;
46
46
  VALUE list;
47
47
 
48
- Data_Get_Struct(self, xmlAttribute, node);
48
+ Noko_Node_Get_Struct(self, xmlAttribute, node);
49
49
 
50
50
  list = rb_ary_new();
51
51
  enm = node->tree;
@@ -25,7 +25,7 @@ new (int argc, VALUE *argv, VALUE klass)
25
25
 
26
26
  rb_scan_args(argc, argv, "2*", &doc, &content, &rest);
27
27
 
28
- Data_Get_Struct(doc, xmlDoc, xml_doc);
28
+ Noko_Node_Get_Struct(doc, xmlDoc, xml_doc);
29
29
 
30
30
  if (!NIL_P(content)) {
31
31
  content_str = (xmlChar *)StringValuePtr(content);
@@ -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
 
@@ -161,7 +165,7 @@ rb_xml_document_root_set(VALUE self, VALUE rb_new_root)
161
165
  rb_obj_class(rb_new_root));
162
166
  }
163
167
 
164
- Data_Get_Struct(rb_new_root, xmlNode, c_new_root);
168
+ Noko_Node_Get_Struct(rb_new_root, xmlNode, c_new_root);
165
169
 
166
170
  /* If the new root's document is not the same as the current document,
167
171
  * then we need to dup the node in to this document. */
@@ -44,7 +44,7 @@ entities(VALUE self)
44
44
  xmlDtdPtr dtd;
45
45
  VALUE hash;
46
46
 
47
- Data_Get_Struct(self, xmlDtd, dtd);
47
+ Noko_Node_Get_Struct(self, xmlDtd, dtd);
48
48
 
49
49
  if (!dtd->entities) { return Qnil; }
50
50
 
@@ -67,7 +67,7 @@ notations(VALUE self)
67
67
  xmlDtdPtr dtd;
68
68
  VALUE hash;
69
69
 
70
- Data_Get_Struct(self, xmlDtd, dtd);
70
+ Noko_Node_Get_Struct(self, xmlDtd, dtd);
71
71
 
72
72
  if (!dtd->notations) { return Qnil; }
73
73
 
@@ -90,7 +90,7 @@ attributes(VALUE self)
90
90
  xmlDtdPtr dtd;
91
91
  VALUE hash;
92
92
 
93
- Data_Get_Struct(self, xmlDtd, dtd);
93
+ Noko_Node_Get_Struct(self, xmlDtd, dtd);
94
94
 
95
95
  hash = rb_hash_new();
96
96
 
@@ -113,7 +113,7 @@ elements(VALUE self)
113
113
  xmlDtdPtr dtd;
114
114
  VALUE hash;
115
115
 
116
- Data_Get_Struct(self, xmlDtd, dtd);
116
+ Noko_Node_Get_Struct(self, xmlDtd, dtd);
117
117
 
118
118
  if (!dtd->elements) { return Qnil; }
119
119
 
@@ -138,8 +138,8 @@ validate(VALUE self, VALUE document)
138
138
  xmlValidCtxtPtr ctxt;
139
139
  VALUE error_list;
140
140
 
141
- Data_Get_Struct(self, xmlDtd, dtd);
142
- Data_Get_Struct(document, xmlDoc, doc);
141
+ Noko_Node_Get_Struct(self, xmlDtd, dtd);
142
+ Noko_Node_Get_Struct(document, xmlDoc, doc);
143
143
  error_list = rb_ary_new();
144
144
 
145
145
  ctxt = xmlNewValidCtxt();
@@ -165,7 +165,7 @@ static VALUE
165
165
  system_id(VALUE self)
166
166
  {
167
167
  xmlDtdPtr dtd;
168
- Data_Get_Struct(self, xmlDtd, dtd);
168
+ Noko_Node_Get_Struct(self, xmlDtd, dtd);
169
169
 
170
170
  if (!dtd->SystemID) { return Qnil; }
171
171
 
@@ -182,7 +182,7 @@ static VALUE
182
182
  external_id(VALUE self)
183
183
  {
184
184
  xmlDtdPtr dtd;
185
- Data_Get_Struct(self, xmlDtd, dtd);
185
+ Noko_Node_Get_Struct(self, xmlDtd, dtd);
186
186
 
187
187
  if (!dtd->ExternalID) { return Qnil; }
188
188
 
@@ -14,7 +14,7 @@ static VALUE
14
14
  element_type(VALUE self)
15
15
  {
16
16
  xmlElementPtr node;
17
- Data_Get_Struct(self, xmlElement, node);
17
+ Noko_Node_Get_Struct(self, xmlElement, node);
18
18
  return INT2NUM((long)node->etype);
19
19
  }
20
20
 
@@ -28,7 +28,7 @@ static VALUE
28
28
  content(VALUE self)
29
29
  {
30
30
  xmlElementPtr node;
31
- Data_Get_Struct(self, xmlElement, node);
31
+ Noko_Node_Get_Struct(self, xmlElement, node);
32
32
 
33
33
  if (!node->content) { return Qnil; }
34
34
 
@@ -48,7 +48,7 @@ static VALUE
48
48
  prefix(VALUE self)
49
49
  {
50
50
  xmlElementPtr node;
51
- Data_Get_Struct(self, xmlElement, node);
51
+ Noko_Node_Get_Struct(self, xmlElement, node);
52
52
 
53
53
  if (!node->prefix) { return Qnil; }
54
54
 
@@ -12,7 +12,7 @@ static VALUE
12
12
  original_content(VALUE self)
13
13
  {
14
14
  xmlEntityPtr node;
15
- Data_Get_Struct(self, xmlEntity, node);
15
+ Noko_Node_Get_Struct(self, xmlEntity, node);
16
16
 
17
17
  if (!node->orig) { return Qnil; }
18
18
 
@@ -29,7 +29,7 @@ static VALUE
29
29
  get_content(VALUE self)
30
30
  {
31
31
  xmlEntityPtr node;
32
- Data_Get_Struct(self, xmlEntity, node);
32
+ Noko_Node_Get_Struct(self, xmlEntity, node);
33
33
 
34
34
  if (!node->content) { return Qnil; }
35
35
 
@@ -46,7 +46,7 @@ static VALUE
46
46
  entity_type(VALUE self)
47
47
  {
48
48
  xmlEntityPtr node;
49
- Data_Get_Struct(self, xmlEntity, node);
49
+ Noko_Node_Get_Struct(self, xmlEntity, node);
50
50
 
51
51
  return INT2NUM((int)node->etype);
52
52
  }
@@ -61,7 +61,7 @@ static VALUE
61
61
  external_id(VALUE self)
62
62
  {
63
63
  xmlEntityPtr node;
64
- Data_Get_Struct(self, xmlEntity, node);
64
+ Noko_Node_Get_Struct(self, xmlEntity, node);
65
65
 
66
66
  if (!node->ExternalID) { return Qnil; }
67
67
 
@@ -78,7 +78,7 @@ static VALUE
78
78
  system_id(VALUE self)
79
79
  {
80
80
  xmlEntityPtr node;
81
- Data_Get_Struct(self, xmlEntity, node);
81
+ Noko_Node_Get_Struct(self, xmlEntity, node);
82
82
 
83
83
  if (!node->SystemID) { return Qnil; }
84
84
 
@@ -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;