nokogiri 1.18.0.rc1 → 1.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7bf663b8257f71a9de9b59b796dc09ffd52f034d2e672f71cdc60f1662d6bf48
4
- data.tar.gz: cca0b07cc0be854f643318b9c4ffd2818b300de46229301116c3a3aaebc3b5fe
3
+ metadata.gz: 2679f31fc93dd9d3024cd46179269b006164ee0f54bc0f65cbc63c8db2d5139c
4
+ data.tar.gz: 6a55139a96f9394360945cc889d55c98c114f0f7007654bb058165eb3973cf34
5
5
  SHA512:
6
- metadata.gz: 40fd1f78757b5ee244e041330f440038429376bb22d8de48746f110b48146ad67be7bd1213b615ad0537bf1520391280f9ccfd5bf9c0a09df01c52aa9be994ee
7
- data.tar.gz: 2b3f433649b041a78e2890202c3036ab1ab4fc3f1cd1467e4847d6965de3b34a4eabdb1331d5e6c9af03085f3348071907637b960a24ea7dbf5d8177d034ebf0
6
+ metadata.gz: 390eeaf3c32f09f2a60efca24c37056911d82f91193eac0fba6ae243e55183999479b42e383781412ec46169cc0fa3ee132b8de696072a06cce82c6283475bef
7
+ data.tar.gz: 7aaf5fa7d8228438de89c8efaf4ab68a5dd42c58ad81b21c9ae85c3c5b5beead377e6ab31bc182ede92a0523d3d20de3feb1473c3f5289b16c34e56057c7d629
data/Gemfile CHANGED
@@ -11,7 +11,7 @@ group :development do
11
11
 
12
12
  # building extensions
13
13
  gem "rake-compiler", "1.2.8"
14
- gem "rake-compiler-dock", "1.7.0.rc1"
14
+ gem "rake-compiler-dock", "1.7.0"
15
15
 
16
16
  # parser generator
17
17
  gem "rexical", "1.0.8"
@@ -34,5 +34,6 @@ end
34
34
  # `bundle config set --local without rdoc`
35
35
  # Then re-run `bundle install`.
36
36
  group :rdoc do
37
- gem "rdoc", "6.9.0"
37
+ gem "rdoc", "6.10.0"
38
+ gem "jar-dependencies", "0.4.1" if RUBY_PLATFORM == "java" # https://github.com/jruby/jruby/issues/7262
38
39
  end
@@ -144,13 +144,6 @@ noko_xml_xpath_context_register_ns(VALUE rb_context, VALUE prefix, VALUE uri)
144
144
 
145
145
  xmlXPathRegisterNs(c_context, (const xmlChar *)StringValueCStr(prefix), ns_uri);
146
146
 
147
- VALUE registered_namespaces = rb_iv_get(rb_context, "@registered_namespaces");
148
- if (NIL_P(uri)) {
149
- rb_hash_delete(registered_namespaces, prefix);
150
- } else {
151
- rb_hash_aset(registered_namespaces, prefix, Qtrue);
152
- }
153
-
154
147
  return rb_context;
155
148
  }
156
149
 
@@ -179,13 +172,6 @@ noko_xml_xpath_context_register_variable(VALUE rb_context, VALUE name, VALUE val
179
172
 
180
173
  xmlXPathRegisterVariable(c_context, (const xmlChar *)StringValueCStr(name), xmlValue);
181
174
 
182
- VALUE registered_variables = rb_iv_get(rb_context, "@registered_variables");
183
- if (NIL_P(value)) {
184
- rb_hash_delete(registered_variables, name);
185
- } else {
186
- rb_hash_aset(registered_variables, name, Qtrue);
187
- }
188
-
189
175
  return rb_context;
190
176
  }
191
177
 
@@ -402,6 +388,7 @@ noko_xml_xpath_context_evaluate(int argc, VALUE *argv, VALUE rb_context)
402
388
  );
403
389
  }
404
390
 
391
+ /* TODO: use xmlXPathSetErrorHandler (as of 2.13.0) */
405
392
  xmlSetStructuredErrorFunc((void *)rb_errors, noko__error_array_pusher);
406
393
  xmlSetGenericErrorFunc((void *)rb_errors, _noko_xml_xpath_context__generic_exception_pusher);
407
394
 
@@ -460,9 +447,6 @@ noko_xml_xpath_context_new(VALUE klass, VALUE rb_node)
460
447
 
461
448
  rb_context = TypedData_Wrap_Struct(klass, &_noko_xml_xpath_context_type, c_context);
462
449
 
463
- rb_iv_set(rb_context, "@registered_namespaces", rb_hash_new());
464
- rb_iv_set(rb_context, "@registered_variables", rb_hash_new());
465
-
466
450
  return rb_context;
467
451
  }
468
452
 
@@ -44,8 +44,8 @@ const unsigned char _gumbo_ascii_table[0x80] = {
44
44
  };
45
45
 
46
46
  // Table generation code.
47
- // clang -DGUMBO_GEN_TABLE=1 ascii.c && ./a.out && rm a.out
48
- #if GUMBO_GEN_TABLE
47
+ // clang -DGUMBO_GEN_TABLE ascii.c && ./a.out && rm a.out
48
+ #ifdef GUMBO_GEN_TABLE
49
49
  #include <stdio.h>
50
50
 
51
51
  int main() {
@@ -318,7 +318,7 @@ static GumboNode* create_node(GumboNodeType type) {
318
318
  return node;
319
319
  }
320
320
 
321
- static GumboNode* new_document_node() {
321
+ static GumboNode* new_document_node(void) {
322
322
  GumboNode* document_node = create_node(GUMBO_NODE_DOCUMENT);
323
323
  document_node->parse_flags = GUMBO_INSERTION_BY_PARSER;
324
324
  gumbo_vector_init(1, &document_node->v.document.children);
@@ -1997,7 +1997,7 @@ static void adjust_svg_tag(GumboToken* token) {
1997
1997
  assert(token->type == GUMBO_TOKEN_START_TAG);
1998
1998
  if (token->v.start_tag.tag == GUMBO_TAG_FOREIGNOBJECT) {
1999
1999
  assert(token->v.start_tag.name == NULL);
2000
- token->v.start_tag.name = "foreignObject";
2000
+ token->v.start_tag.name = (char *)"foreignObject";
2001
2001
  } else if (token->v.start_tag.tag == GUMBO_TAG_UNKNOWN) {
2002
2002
  assert(token->v.start_tag.name);
2003
2003
  const StringReplacement *replacement = gumbo_get_svg_tag_replacement(
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Nokogiri
4
4
  # The version of Nokogiri you are using
5
- VERSION = "1.18.0.rc1"
5
+ VERSION = "1.18.0"
6
6
  end
@@ -261,36 +261,13 @@ module Nokogiri
261
261
  end
262
262
 
263
263
  def xpath_impl(node, path, handler, ns, binds)
264
- get_xpath_context(node) do |context|
265
- context.register_namespaces(ns)
266
- context.register_variables(binds)
264
+ context = XPathContext.new(node)
265
+ context.register_namespaces(ns)
266
+ context.register_variables(binds)
267
267
 
268
- path = path.gsub("xmlns:", " :") unless Nokogiri.uses_libxml?
268
+ path = path.gsub("xmlns:", " :") unless Nokogiri.uses_libxml?
269
269
 
270
- context.evaluate(path, handler)
271
- end
272
- end
273
-
274
- if Nokogiri.uses_libxml? && ENV["NOKOGIRI_DEOPTIMIZE_XPATH"].nil? # env var is an escape hatch
275
- # optimized path
276
- def get_xpath_context(node)
277
- context = Thread.current.thread_variable_get(:nokogiri_xpath_context)
278
- if context
279
- context.node = node
280
- else
281
- context = Thread.current.thread_variable_set(:nokogiri_xpath_context, XPathContext.new(node))
282
- end
283
-
284
- begin
285
- yield context
286
- ensure
287
- context.reset
288
- end
289
- end
290
- else
291
- def get_xpath_context(node)
292
- yield XPathContext.new(node)
293
- end
270
+ context.evaluate(path, handler)
294
271
  end
295
272
  end
296
273
  end
@@ -22,28 +22,6 @@ module Nokogiri
22
22
  register_variable(key, value)
23
23
  end
24
24
  end
25
-
26
- if Nokogiri.uses_libxml?
27
- def reset
28
- return unless
29
-
30
- @registered_namespaces.each do |key, _|
31
- register_ns(key, nil)
32
- end
33
- unless @registered_namespaces.empty?
34
- warn "Nokogiri::XML::XPathContext#reset: unexpected registered namespaces: #{@registered_namespaces.keys}"
35
- @registered_namespaces.clear
36
- end
37
-
38
- @registered_variables.each do |key, _|
39
- register_variable(key, nil)
40
- end
41
- unless @registered_variables.empty?
42
- warn "Nokogiri::XML::XPathContext#reset: unexpected registered variables: #{@registered_variables.keys}"
43
- @registered_variables.clear
44
- end
45
- end
46
- end
47
25
  end
48
26
  end
49
27
  end
@@ -0,0 +1,244 @@
1
+ From d3e3526111097560cf7c002613e2cb1d469b59e0 Mon Sep 17 00:00:00 2001
2
+ From: Nick Wellnhofer <wellnhofer@aevum.de>
3
+ Date: Sat, 21 Dec 2024 16:03:46 +0100
4
+ Subject: [PATCH] xpath: Use separate static hash table for standard functions
5
+
6
+ This avoids registering standard functions when creating an XPath
7
+ context.
8
+
9
+ Lookup of extension functions is a bit slower now, but ultimately, all
10
+ function lookups should be moved to the compilation phase.
11
+
12
+ (cherry picked from commit bf5fcf6e646bb51a0f6a3655a1d64bea97274867)
13
+ ---
14
+ xpath.c | 170 ++++++++++++++++++++++++++++++++------------------------
15
+ 1 file changed, 98 insertions(+), 72 deletions(-)
16
+
17
+ diff --git a/xpath.c b/xpath.c
18
+ index 485d7747..21711653 100644
19
+ --- a/xpath.c
20
+ +++ b/xpath.c
21
+ @@ -136,11 +136,48 @@
22
+
23
+ #if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
24
+
25
+ -/************************************************************************
26
+ - * *
27
+ - * Floating point stuff *
28
+ - * *
29
+ - ************************************************************************/
30
+ +static void
31
+ +xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs);
32
+ +
33
+ +static const struct {
34
+ + const char *name;
35
+ + xmlXPathFunction func;
36
+ +} xmlXPathStandardFunctions[] = {
37
+ + { "boolean", xmlXPathBooleanFunction },
38
+ + { "ceiling", xmlXPathCeilingFunction },
39
+ + { "count", xmlXPathCountFunction },
40
+ + { "concat", xmlXPathConcatFunction },
41
+ + { "contains", xmlXPathContainsFunction },
42
+ + { "id", xmlXPathIdFunction },
43
+ + { "false", xmlXPathFalseFunction },
44
+ + { "floor", xmlXPathFloorFunction },
45
+ + { "last", xmlXPathLastFunction },
46
+ + { "lang", xmlXPathLangFunction },
47
+ + { "local-name", xmlXPathLocalNameFunction },
48
+ + { "not", xmlXPathNotFunction },
49
+ + { "name", xmlXPathNameFunction },
50
+ + { "namespace-uri", xmlXPathNamespaceURIFunction },
51
+ + { "normalize-space", xmlXPathNormalizeFunction },
52
+ + { "number", xmlXPathNumberFunction },
53
+ + { "position", xmlXPathPositionFunction },
54
+ + { "round", xmlXPathRoundFunction },
55
+ + { "string", xmlXPathStringFunction },
56
+ + { "string-length", xmlXPathStringLengthFunction },
57
+ + { "starts-with", xmlXPathStartsWithFunction },
58
+ + { "substring", xmlXPathSubstringFunction },
59
+ + { "substring-before", xmlXPathSubstringBeforeFunction },
60
+ + { "substring-after", xmlXPathSubstringAfterFunction },
61
+ + { "sum", xmlXPathSumFunction },
62
+ + { "true", xmlXPathTrueFunction },
63
+ + { "translate", xmlXPathTranslateFunction }
64
+ +};
65
+ +
66
+ +#define NUM_STANDARD_FUNCTIONS \
67
+ + (sizeof(xmlXPathStandardFunctions) / sizeof(xmlXPathStandardFunctions[0]))
68
+ +
69
+ +#define SF_HASH_SIZE 64
70
+ +
71
+ +static unsigned char xmlXPathSFHash[SF_HASH_SIZE];
72
+
73
+ double xmlXPathNAN = 0.0;
74
+ double xmlXPathPINF = 0.0;
75
+ @@ -156,6 +193,18 @@ xmlXPathInit(void) {
76
+ xmlInitParser();
77
+ }
78
+
79
+ +ATTRIBUTE_NO_SANITIZE_INTEGER
80
+ +static unsigned
81
+ +xmlXPathSFComputeHash(const xmlChar *name) {
82
+ + unsigned hashValue = 5381;
83
+ + const xmlChar *ptr;
84
+ +
85
+ + for (ptr = name; *ptr; ptr++)
86
+ + hashValue = hashValue * 33 + *ptr;
87
+ +
88
+ + return(hashValue);
89
+ +}
90
+ +
91
+ /**
92
+ * xmlInitXPathInternal:
93
+ *
94
+ @@ -164,6 +213,8 @@ xmlXPathInit(void) {
95
+ ATTRIBUTE_NO_SANITIZE("float-divide-by-zero")
96
+ void
97
+ xmlInitXPathInternal(void) {
98
+ + size_t i;
99
+ +
100
+ #if defined(NAN) && defined(INFINITY)
101
+ xmlXPathNAN = NAN;
102
+ xmlXPathPINF = INFINITY;
103
+ @@ -175,8 +226,34 @@ xmlInitXPathInternal(void) {
104
+ xmlXPathPINF = 1.0 / zero;
105
+ xmlXPathNINF = -xmlXPathPINF;
106
+ #endif
107
+ +
108
+ + /*
109
+ + * Initialize hash table for standard functions
110
+ + */
111
+ +
112
+ + for (i = 0; i < SF_HASH_SIZE; i++)
113
+ + xmlXPathSFHash[i] = UCHAR_MAX;
114
+ +
115
+ + for (i = 0; i < NUM_STANDARD_FUNCTIONS; i++) {
116
+ + const char *name = xmlXPathStandardFunctions[i].name;
117
+ + int bucketIndex = xmlXPathSFComputeHash(BAD_CAST name) % SF_HASH_SIZE;
118
+ +
119
+ + while (xmlXPathSFHash[bucketIndex] != UCHAR_MAX) {
120
+ + bucketIndex += 1;
121
+ + if (bucketIndex >= SF_HASH_SIZE)
122
+ + bucketIndex = 0;
123
+ + }
124
+ +
125
+ + xmlXPathSFHash[bucketIndex] = i;
126
+ + }
127
+ }
128
+
129
+ +/************************************************************************
130
+ + * *
131
+ + * Floating point stuff *
132
+ + * *
133
+ + ************************************************************************/
134
+ +
135
+ /**
136
+ * xmlXPathIsNaN:
137
+ * @val: a double value
138
+ @@ -3979,18 +4056,6 @@ xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt,
139
+ */
140
+ xmlXPathFunction
141
+ xmlXPathFunctionLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
142
+ - if (ctxt == NULL)
143
+ - return (NULL);
144
+ -
145
+ - if (ctxt->funcLookupFunc != NULL) {
146
+ - xmlXPathFunction ret;
147
+ - xmlXPathFuncLookupFunc f;
148
+ -
149
+ - f = ctxt->funcLookupFunc;
150
+ - ret = f(ctxt->funcLookupData, name, NULL);
151
+ - if (ret != NULL)
152
+ - return(ret);
153
+ - }
154
+ return(xmlXPathFunctionLookupNS(ctxt, name, NULL));
155
+ }
156
+
157
+ @@ -4015,6 +4080,22 @@ xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
158
+ if (name == NULL)
159
+ return(NULL);
160
+
161
+ + if (ns_uri == NULL) {
162
+ + int bucketIndex = xmlXPathSFComputeHash(name) % SF_HASH_SIZE;
163
+ +
164
+ + while (xmlXPathSFHash[bucketIndex] != UCHAR_MAX) {
165
+ + int funcIndex = xmlXPathSFHash[bucketIndex];
166
+ +
167
+ + if (strcmp(xmlXPathStandardFunctions[funcIndex].name,
168
+ + (char *) name) == 0)
169
+ + return(xmlXPathStandardFunctions[funcIndex].func);
170
+ +
171
+ + bucketIndex += 1;
172
+ + if (bucketIndex >= SF_HASH_SIZE)
173
+ + bucketIndex = 0;
174
+ + }
175
+ + }
176
+ +
177
+ if (ctxt->funcLookupFunc != NULL) {
178
+ xmlXPathFuncLookupFunc f;
179
+
180
+ @@ -13494,61 +13575,6 @@ xmlXPathEscapeUriFunction(xmlXPathParserContextPtr ctxt, int nargs) {
181
+ void
182
+ xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt)
183
+ {
184
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"boolean",
185
+ - xmlXPathBooleanFunction);
186
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"ceiling",
187
+ - xmlXPathCeilingFunction);
188
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"count",
189
+ - xmlXPathCountFunction);
190
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"concat",
191
+ - xmlXPathConcatFunction);
192
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"contains",
193
+ - xmlXPathContainsFunction);
194
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"id",
195
+ - xmlXPathIdFunction);
196
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"false",
197
+ - xmlXPathFalseFunction);
198
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"floor",
199
+ - xmlXPathFloorFunction);
200
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"last",
201
+ - xmlXPathLastFunction);
202
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"lang",
203
+ - xmlXPathLangFunction);
204
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"local-name",
205
+ - xmlXPathLocalNameFunction);
206
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"not",
207
+ - xmlXPathNotFunction);
208
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"name",
209
+ - xmlXPathNameFunction);
210
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"namespace-uri",
211
+ - xmlXPathNamespaceURIFunction);
212
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"normalize-space",
213
+ - xmlXPathNormalizeFunction);
214
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"number",
215
+ - xmlXPathNumberFunction);
216
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"position",
217
+ - xmlXPathPositionFunction);
218
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"round",
219
+ - xmlXPathRoundFunction);
220
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"string",
221
+ - xmlXPathStringFunction);
222
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"string-length",
223
+ - xmlXPathStringLengthFunction);
224
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"starts-with",
225
+ - xmlXPathStartsWithFunction);
226
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring",
227
+ - xmlXPathSubstringFunction);
228
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring-before",
229
+ - xmlXPathSubstringBeforeFunction);
230
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring-after",
231
+ - xmlXPathSubstringAfterFunction);
232
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"sum",
233
+ - xmlXPathSumFunction);
234
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"true",
235
+ - xmlXPathTrueFunction);
236
+ - xmlXPathRegisterFunc(ctxt, (const xmlChar *)"translate",
237
+ - xmlXPathTranslateFunction);
238
+ -
239
+ xmlXPathRegisterFuncNS(ctxt, (const xmlChar *)"escape-uri",
240
+ (const xmlChar *)"http://www.w3.org/2002/08/xquery-functions",
241
+ xmlXPathEscapeUriFunction);
242
+ --
243
+ 2.47.1
244
+
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.18.0.rc1
4
+ version: 1.18.0
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: 2024-12-16 00:00:00.000000000 Z
23
+ date: 2024-12-25 00:00:00.000000000 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mini_portile2
@@ -272,6 +272,7 @@ files:
272
272
  - patches/libxml2/0009-allow-wildcard-namespaces.patch
273
273
  - patches/libxml2/0010-update-config.guess-and-config.sub-for-libxml2.patch
274
274
  - patches/libxml2/0011-rip-out-libxml2-s-libc_single_threaded-support.patch
275
+ - patches/libxml2/0019-xpath-Use-separate-static-hash-table-for-standard-fu.patch
275
276
  - patches/libxslt/0001-update-config.guess-and-config.sub-for-libxslt.patch
276
277
  - ports/archives/libxml2-2.13.5.tar.xz
277
278
  - ports/archives/libxslt-1.1.42.tar.xz
@@ -298,11 +299,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
298
299
  version: 3.1.0
299
300
  required_rubygems_version: !ruby/object:Gem::Requirement
300
301
  requirements:
301
- - - ">"
302
+ - - ">="
302
303
  - !ruby/object:Gem::Version
303
- version: 1.3.1
304
+ version: '0'
304
305
  requirements: []
305
- rubygems_version: 3.3.22
306
+ rubygems_version: 3.5.11
306
307
  signing_key:
307
308
  specification_version: 4
308
309
  summary: Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby.