nokogiri 1.13.5-java → 1.13.6-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: f6392139b32a94f0c4b094a483fdff4f0863d0981ef8dcd5097e1321786f1fe4
4
- data.tar.gz: 195bde6f928df5954bc6826efcf98bb684f4b84884fe0da75226b673fdd23a19
3
+ metadata.gz: 136660db16a0cd46b0d33cb862e47e021596de26c7133680db64cd40dffc78f4
4
+ data.tar.gz: 6dd6910717f54738591f4f5c88a8b465d0896e3a12544ab4b1f5fddd0f28476a
5
5
  SHA512:
6
- metadata.gz: e254d1035c127c9bd75c5b59f08e239e1dcc611f241fdf34ae3d0645ef41cede958d202a494f24aa0857cf969621df87b6fd40767b4ccb192a04020cc5e85c0b
7
- data.tar.gz: 0d619fde6b4533de4942138947339366277ebf072beb4d9ff854e6c623a5857c84ef4afa5b621ebbc4d18fffcd33074226fe6e0f692ed7d3485530ab0cc0ea1f
6
+ metadata.gz: 2fca1d2d49c7d03ce5a672abccb64c4854432f7fc03f8909df0b761ae014db384e65a0b9707b6e407beec2a4f034e4a7979bf37fc086a5a61b5554e49486a5ac
7
+ data.tar.gz: 11df230fc19d7da7070ff264e1069a3aa03b68bb77a3a10ef75934b8ae923121b46dc8f20c88ba5fc321870ab9b7e4df7fa2aaeb877d47be0c6e793109471c7d
@@ -231,6 +231,13 @@ public class Html4SaxParserContext extends XmlSaxParserContext
231
231
  IRubyObject data,
232
232
  IRubyObject encoding)
233
233
  {
234
+ if (!(data instanceof RubyString)) {
235
+ throw context.getRuntime().newTypeError("data must be kind_of String");
236
+ }
237
+ if (!(encoding instanceof RubyString)) {
238
+ throw context.getRuntime().newTypeError("data must be kind_of String");
239
+ }
240
+
234
241
  Html4SaxParserContext ctx = Html4SaxParserContext.newInstance(context.runtime, (RubyClass) klass);
235
242
  ctx.setInputSourceFile(context, data);
236
243
  String javaEncoding = findEncodingName(context, encoding);
@@ -247,6 +254,10 @@ public class Html4SaxParserContext extends XmlSaxParserContext
247
254
  IRubyObject data,
248
255
  IRubyObject encoding)
249
256
  {
257
+ if (!(encoding instanceof RubyFixnum)) {
258
+ throw context.getRuntime().newTypeError("encoding must be kind_of String");
259
+ }
260
+
250
261
  Html4SaxParserContext ctx = Html4SaxParserContext.newInstance(context.runtime, (RubyClass) klass);
251
262
  ctx.setIOInputSource(context, data, context.nil);
252
263
  String javaEncoding = findEncodingName(context, encoding);
@@ -130,9 +130,12 @@ public class XmlSaxParserContext extends ParserContext
130
130
  parse_io(ThreadContext context,
131
131
  IRubyObject klazz,
132
132
  IRubyObject data,
133
- IRubyObject enc)
133
+ IRubyObject encoding)
134
134
  {
135
- //int encoding = (int)enc.convertToInteger().getLongValue();
135
+ // check the type of the unused encoding to match behavior of CRuby
136
+ if (!(encoding instanceof RubyFixnum)) {
137
+ throw context.getRuntime().newTypeError("encoding must be kind_of String");
138
+ }
136
139
  final Ruby runtime = context.runtime;
137
140
  XmlSaxParserContext ctx = newInstance(runtime, (RubyClass) klazz);
138
141
  ctx.initialize(runtime);
@@ -58,6 +58,12 @@ public abstract class ParserContext extends RubyObject
58
58
  source = new InputSource();
59
59
  ParserContext.setUrl(context, source, url);
60
60
 
61
+ Ruby ruby = context.getRuntime();
62
+
63
+ if (!(data.respondsTo("read"))) {
64
+ throw ruby.newTypeError("must respond to :read");
65
+ }
66
+
61
67
  source.setByteStream(new IOInputStream(data));
62
68
  if (java_encoding != null) {
63
69
  source.setEncoding(java_encoding);
@@ -73,7 +79,7 @@ public abstract class ParserContext extends RubyObject
73
79
  Ruby ruby = context.getRuntime();
74
80
 
75
81
  if (!(data instanceof RubyString)) {
76
- throw ruby.newArgumentError("must be kind_of String");
82
+ throw ruby.newTypeError("must be kind_of String");
77
83
  }
78
84
 
79
85
  RubyString stringData = (RubyString) data;
@@ -19,9 +19,8 @@ parse_memory(VALUE klass, VALUE data, VALUE encoding)
19
19
  {
20
20
  htmlParserCtxtPtr ctxt;
21
21
 
22
- if (NIL_P(data)) {
23
- rb_raise(rb_eArgError, "data cannot be nil");
24
- }
22
+ Check_Type(data, T_STRING);
23
+
25
24
  if (!(int)RSTRING_LEN(data)) {
26
25
  rb_raise(rb_eRuntimeError, "data cannot be empty");
27
26
  }
@@ -2,6 +2,8 @@
2
2
 
3
3
  VALUE cNokogiriXmlSaxParserContext ;
4
4
 
5
+ static ID id_read;
6
+
5
7
  static void
6
8
  deallocate(xmlParserCtxtPtr ctxt)
7
9
  {
@@ -26,6 +28,10 @@ parse_io(VALUE klass, VALUE io, VALUE encoding)
26
28
  xmlParserCtxtPtr ctxt;
27
29
  xmlCharEncoding enc = (xmlCharEncoding)NUM2INT(encoding);
28
30
 
31
+ if (!rb_respond_to(io, id_read)) {
32
+ rb_raise(rb_eTypeError, "argument expected to respond to :read");
33
+ }
34
+
29
35
  ctxt = xmlCreateIOParserCtxt(NULL, NULL,
30
36
  (xmlInputReadCallback)noko_io_read,
31
37
  (xmlInputCloseCallback)noko_io_close,
@@ -62,9 +68,8 @@ parse_memory(VALUE klass, VALUE data)
62
68
  {
63
69
  xmlParserCtxtPtr ctxt;
64
70
 
65
- if (NIL_P(data)) {
66
- rb_raise(rb_eArgError, "data cannot be nil");
67
- }
71
+ Check_Type(data, T_STRING);
72
+
68
73
  if (!(int)RSTRING_LEN(data)) {
69
74
  rb_raise(rb_eRuntimeError, "data cannot be empty");
70
75
  }
@@ -278,4 +283,6 @@ noko_init_xml_sax_parser_context()
278
283
  rb_define_method(cNokogiriXmlSaxParserContext, "recovery", get_recovery, 0);
279
284
  rb_define_method(cNokogiriXmlSaxParserContext, "line", line, 0);
280
285
  rb_define_method(cNokogiriXmlSaxParserContext, "column", column, 0);
286
+
287
+ id_read = rb_intern("read");
281
288
  }
@@ -28,7 +28,7 @@ module Nokogiri
28
28
  ###
29
29
  # Parse html stored in +data+ using +encoding+
30
30
  def parse_memory(data, encoding = "UTF-8")
31
- raise ArgumentError unless data
31
+ raise TypeError unless String === data
32
32
  return if data.empty?
33
33
 
34
34
  ctx = ParserContext.memory(data, encoding)
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.5"
5
+ VERSION = "1.13.6"
6
6
  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.13.5
4
+ version: 1.13.6
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-05-04 00:00:00.000000000 Z
23
+ date: 2022-05-08 00:00:00.000000000 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  requirement: !ruby/object:Gem::Requirement