nokogiri 1.18.0.rc1-java → 1.18.2-java

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: 9e025518efd4b954f720962dc521a275c720e4ed5ca35169be6fd8db2ade55b5
4
- data.tar.gz: 15ae77aaf7577b48a2b0536f15453b9ee45b9a640bc7c46c50225fb6390a0ef9
3
+ metadata.gz: a3689c4e910dbcb513805bbcdc96d14eaf261881dcd1542ea2f8c782ca3b2bae
4
+ data.tar.gz: 0c74a67a5963393ddb53d183670bfa168f6ccff52643cab3cd8391a6e9f1194e
5
5
  SHA512:
6
- metadata.gz: 6c8de60d916ed408598361aea0916be561766da29a3232f56bbcd4e29bf95811aa4aac6a1ad21086d9694d1811f0aec47e72c01551854e4354fab5938a315dd3
7
- data.tar.gz: 3e83a4ffdbb3723c8e50dc87a4c02e617e07ffbe9352f0ce0a9dbb61f1d0dbf05b336066e06bcc745ffc7051efbce5eb7f7178d1281eb17a0c6ec7308d2493d3
6
+ metadata.gz: 0b492488732e6dc6055c276fc6afb72f3a79a58c7e898110a308cdfd8d0ed50161439167c18011212d88622ad85b79ccfaef7ea82fc3dbaf089784007ec42736
7
+ data.tar.gz: 0bd99d7daaf14f7363689f4019a90bece65e76f4cbec43865c4ccc50b600108f20ef79a4284e79d7550a4108563e29d0c93ff6f9c93e9a675f828bdf02996b64
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,5 @@ 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" unless RUBY_PLATFORM == "java" || ENV["CI"]
38
38
  end
@@ -154,7 +154,11 @@ public class XmlXpathContext extends RubyObject
154
154
  public IRubyObject
155
155
  register_ns(IRubyObject prefix, IRubyObject uri)
156
156
  {
157
- nsContext.registerNamespace(prefix.asJavaString(), uri.asJavaString());
157
+ if (uri.isNil()) {
158
+ nsContext.deregisterNamespace(prefix.asJavaString());
159
+ } else {
160
+ nsContext.registerNamespace(prefix.asJavaString(), uri.asJavaString());
161
+ }
158
162
  return this;
159
163
  }
160
164
 
@@ -169,10 +173,23 @@ public class XmlXpathContext extends RubyObject
169
173
  variableResolver = NokogiriXPathVariableResolver.create();
170
174
  this.variableResolver = variableResolver;
171
175
  }
172
- variableResolver.registerVariable(name.asJavaString(), value.asJavaString());
176
+ if (value.isNil()) {
177
+ variableResolver.deregisterVariable(name.asJavaString());
178
+ } else {
179
+ variableResolver.registerVariable(name.asJavaString(), value.asJavaString());
180
+ }
173
181
  return this;
174
182
  }
175
183
 
184
+ @JRubyMethod(name = "node=")
185
+ public IRubyObject
186
+ set_node(ThreadContext context, IRubyObject rb_node)
187
+ {
188
+ this.context = (XmlNode) rb_node;
189
+ return rb_node;
190
+ }
191
+
192
+
176
193
  private IRubyObject
177
194
  node_set(ThreadContext context, String expr, IRubyObject handler)
178
195
  {
@@ -107,4 +107,10 @@ public final class NokogiriNamespaceContext implements NamespaceContext
107
107
  register.put(prefix, uri);
108
108
  }
109
109
 
110
+ public void
111
+ deregisterNamespace(String prefix)
112
+ {
113
+ if ("xmlns".equals(prefix)) { prefix = ""; }
114
+ register.remove(prefix);
115
+ }
110
116
  }
@@ -34,4 +34,10 @@ public class NokogiriXPathVariableResolver implements XPathVariableResolver
34
34
  {
35
35
  variables.put(new QName(name), value);
36
36
  }
37
+ public void
38
+ deregisterVariable(String name)
39
+ {
40
+ variables.remove(new QName(name));
41
+ }
42
+
37
43
  }
@@ -102,7 +102,10 @@ noko_xml_sax_parser_context_s_native_io(VALUE rb_class, VALUE rb_io, VALUE rb_en
102
102
  c_context->sax = NULL;
103
103
  }
104
104
 
105
- return noko_xml_sax_parser_context_wrap(rb_class, c_context);
105
+ VALUE rb_context = noko_xml_sax_parser_context_wrap(rb_class, c_context);
106
+ rb_iv_set(rb_context, "@input", rb_io);
107
+
108
+ return rb_context;
106
109
  }
107
110
 
108
111
  /* :nodoc: */
@@ -154,7 +157,10 @@ noko_xml_sax_parser_context_s_native_memory(VALUE rb_class, VALUE rb_input, VALU
154
157
  c_context->sax = NULL;
155
158
  }
156
159
 
157
- return noko_xml_sax_parser_context_wrap(rb_class, c_context);
160
+ VALUE rb_context = noko_xml_sax_parser_context_wrap(rb_class, c_context);
161
+ rb_iv_set(rb_context, "@input", rb_input);
162
+
163
+ return rb_context;
158
164
  }
159
165
 
160
166
  /*
@@ -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
 
@@ -283,7 +283,8 @@ module Nokogiri
283
283
  else
284
284
  node.value.join(":")
285
285
  end
286
- elsif @namespaces&.key?("xmlns") # apply the default namespace if it's declared
286
+ elsif node.value.first != "*" && @namespaces&.key?("xmlns")
287
+ # apply the default namespace (if one is present) to a non-wildcard selector
287
288
  "xmlns:#{node.value.first}"
288
289
  else
289
290
  node.value.first
Binary file
@@ -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.2"
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
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.2
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: 2024-12-16 00:00:00.000000000 Z
23
+ date: 2025-01-19 00:00:00.000000000 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jar-dependencies
@@ -343,9 +343,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
343
343
  version: 3.1.0
344
344
  required_rubygems_version: !ruby/object:Gem::Requirement
345
345
  requirements:
346
- - - ">"
346
+ - - ">="
347
347
  - !ruby/object:Gem::Version
348
- version: 1.3.1
348
+ version: '0'
349
349
  requirements:
350
350
  - jar isorelax, isorelax, 20030108
351
351
  - jar org.nokogiri, nekodtd, 0.1.11.noko2