nokogiri 1.11.0 → 1.11.1

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: a800fb24c3e54cee605b4655bfea25d8fecb99d003b4c2cd67be74d22b9602a6
4
- data.tar.gz: 1d965115bb1db88fc896d34af1372419d97ecde7e84cb2e4f3f0f0c519cab87e
3
+ metadata.gz: 9e233fa79ef3ba9506ebbb61031908fff5586ec2b6fbb63d612e3d1019407812
4
+ data.tar.gz: 3a365658391d3c678e54264b70828d8423ca383694bc1b97c73f69997901cac9
5
5
  SHA512:
6
- metadata.gz: 1776b8569e5ce07bc8cc21c3cd079418c7e0a002a056a8c3ad1b1c28380e6b878f461be8d2e0134ac853c24ed3601e6ee880f30b8b6f3e6b136acb40583f8326
7
- data.tar.gz: 9b868c176d1ede0e88ea6feee367652e5cba3b72ab87dddd1e991f0df1c6ffe376e3ad49bd5cc6fd0fbb495b47f333d0e89f4df530f22162835f811178ac82a6
6
+ metadata.gz: c0ce873146805ff6f3834182cad276114a2a1b5e91f21be787ba468328a692cb1c58663b23896cb1a851f971d85267593b96472c4c3f7027fa44e2e7718155e3
7
+ data.tar.gz: 29ce5dd59f87404aa28e6c2415222c6c30368f0c4e9feb06f66f937231402c6d3201395cc7fb9c45e418577656a4a7f18ec22b0567551c0530d313feee0d4a87
@@ -92,6 +92,8 @@ parse_with(VALUE self, VALUE sax_handler)
92
92
  ctxt->sax = sax;
93
93
  ctxt->userData = (void *)NOKOGIRI_SAX_TUPLE_NEW(ctxt, sax_handler);
94
94
 
95
+ xmlSetStructuredErrorFunc(NULL, NULL);
96
+
95
97
  rb_ensure(parse_doc, (VALUE)ctxt, parse_doc_finalize, (VALUE)ctxt);
96
98
 
97
99
  return self;
@@ -9,9 +9,10 @@
9
9
  static VALUE native_write(VALUE self, VALUE _chunk, VALUE _last_chunk)
10
10
  {
11
11
  xmlParserCtxtPtr ctx;
12
- const char * chunk = NULL;
13
- int size = 0;
14
-
12
+ const char * chunk = NULL;
13
+ int size = 0;
14
+ int status = 0;
15
+ libxmlStructuredErrorHandlerState handler_state;
15
16
 
16
17
  Data_Get_Struct(self, xmlParserCtxt, ctx);
17
18
 
@@ -20,11 +21,16 @@ static VALUE native_write(VALUE self, VALUE _chunk, VALUE _last_chunk)
20
21
  size = (int)RSTRING_LEN(_chunk);
21
22
  }
22
23
 
23
- if(htmlParseChunk(ctx, chunk, size, Qtrue == _last_chunk ? 1 : 0)) {
24
- if (!(ctx->options & XML_PARSE_RECOVER)) {
25
- xmlErrorPtr e = xmlCtxtGetLastError(ctx);
26
- Nokogiri_error_raise(NULL, e);
27
- }
24
+ Nokogiri_structured_error_func_save_and_set(&handler_state, NULL, NULL);
25
+
26
+ status = htmlParseChunk(ctx, chunk, size, Qtrue == _last_chunk ? 1 : 0);
27
+
28
+ Nokogiri_structured_error_func_restore(&handler_state);
29
+
30
+ if ((status != 0) && !(ctx->options & XML_PARSE_RECOVER)) {
31
+ // TODO: there appear to be no tests for this block
32
+ xmlErrorPtr e = xmlCtxtGetLastError(ctx);
33
+ Nokogiri_error_raise(NULL, e);
28
34
  }
29
35
 
30
36
  return self;
@@ -1,5 +1,7 @@
1
1
  #include <nokogiri.h>
2
2
 
3
+ void init_test_global_handlers(); /* in lieu of test_global_handlers.h */
4
+
3
5
  VALUE mNokogiri ;
4
6
  VALUE mNokogiriXml ;
5
7
  VALUE mNokogiriHtml ;
@@ -132,4 +134,5 @@ void Init_nokogiri()
132
134
  init_xml_relax_ng();
133
135
  init_nokogiri_io();
134
136
  init_xml_encoding_handler();
137
+ init_test_global_handlers();
135
138
  }
@@ -0,0 +1,41 @@
1
+ #include <nokogiri.h>
2
+ #include "libxml/xmlerror.h"
3
+
4
+ static VALUE foreign_error_handler_block = Qnil;
5
+
6
+ static void foreign_error_handler(void* user_data, xmlErrorPtr c_error)
7
+ {
8
+ rb_funcall(foreign_error_handler_block, rb_intern("call"), 0);
9
+ }
10
+
11
+ /*
12
+ * call-seq:
13
+ * __foreign_error_handler { ... } -> nil
14
+ *
15
+ * Override libxml2's global error handlers to call the block. This method thus has very little
16
+ * value except to test that Nokogiri is properly setting error handlers elsewhere in the code. See
17
+ * test/helper.rb for how this is being used.
18
+ */
19
+ static VALUE
20
+ rb_foreign_error_handler(VALUE klass)
21
+ {
22
+ rb_need_block();
23
+ foreign_error_handler_block = rb_block_proc();
24
+ xmlSetStructuredErrorFunc(NULL, foreign_error_handler);
25
+ return Qnil;
26
+ }
27
+
28
+ /*
29
+ * Document-module: Nokogiri::Test
30
+ *
31
+ * The Nokogiri::Test module should only be used for testing Nokogiri.
32
+ * Do NOT use this outside of the Nokogiri test suite.
33
+ */
34
+ void
35
+ init_test_global_handlers()
36
+ {
37
+ VALUE mNokogiri = rb_define_module("Nokogiri");
38
+ VALUE mNokogiriTest = rb_define_module_under(mNokogiri, "Test");
39
+
40
+ rb_define_singleton_method(mNokogiriTest, "__foreign_error_handler", rb_foreign_error_handler, 0);
41
+ }
@@ -120,6 +120,8 @@ parse_with(VALUE self, VALUE sax_handler)
120
120
  ctxt->sax = sax;
121
121
  ctxt->userData = (void *)NOKOGIRI_SAX_TUPLE_NEW(ctxt, sax_handler);
122
122
 
123
+ xmlSetStructuredErrorFunc(NULL, NULL);
124
+
123
125
  rb_ensure(parse_doc, (VALUE)ctxt, parse_doc_finalize, (VALUE)ctxt);
124
126
 
125
127
  return Qnil;
@@ -35,6 +35,8 @@ static VALUE native_write(VALUE self, VALUE _chunk, VALUE _last_chunk)
35
35
  size = (int)RSTRING_LEN(_chunk);
36
36
  }
37
37
 
38
+ xmlSetStructuredErrorFunc(NULL, NULL);
39
+
38
40
  if (xmlParseChunk(ctx, chunk, size, Qtrue == _last_chunk ? 1 : 0)) {
39
41
  if (!(ctx->options & XML_PARSE_RECOVER)) {
40
42
  xmlErrorPtr e = xmlCtxtGetLastError(ctx);
@@ -1,5 +1,28 @@
1
1
  #include <xml_syntax_error.h>
2
2
 
3
+ void
4
+ Nokogiri_structured_error_func_save(libxmlStructuredErrorHandlerState *handler_state)
5
+ {
6
+ /* this method is tightly coupled to the implementation of xmlSetStructuredErrorFunc */
7
+ handler_state->user_data = xmlStructuredErrorContext;
8
+ handler_state->handler = xmlStructuredError;
9
+ }
10
+
11
+ void
12
+ Nokogiri_structured_error_func_save_and_set(libxmlStructuredErrorHandlerState *handler_state,
13
+ void *user_data,
14
+ xmlStructuredErrorFunc handler)
15
+ {
16
+ Nokogiri_structured_error_func_save(handler_state);
17
+ xmlSetStructuredErrorFunc(user_data, handler);
18
+ }
19
+
20
+ void
21
+ Nokogiri_structured_error_func_restore(libxmlStructuredErrorHandlerState *handler_state)
22
+ {
23
+ xmlSetStructuredErrorFunc(handler_state->user_data, handler_state->handler);
24
+ }
25
+
3
26
  void Nokogiri_error_array_pusher(void * ctx, xmlErrorPtr error)
4
27
  {
5
28
  VALUE list = (VALUE)ctx;
@@ -3,11 +3,23 @@
3
3
 
4
4
  #include <nokogiri.h>
5
5
 
6
+ typedef struct _libxmlStructuredErrorHandlerState {
7
+ void *user_data;
8
+ xmlStructuredErrorFunc handler;
9
+ } libxmlStructuredErrorHandlerState ;
10
+
6
11
  void init_xml_syntax_error();
12
+
13
+ void Nokogiri_structured_error_func_save(libxmlStructuredErrorHandlerState *handler_state);
14
+ void Nokogiri_structured_error_func_save_and_set(libxmlStructuredErrorHandlerState *handler_state,
15
+ void *user_data,
16
+ xmlStructuredErrorFunc handler);
17
+ void Nokogiri_structured_error_func_restore(libxmlStructuredErrorHandlerState *handler_state);
18
+
7
19
  VALUE Nokogiri_wrap_xml_syntax_error(xmlErrorPtr error);
8
- void Nokogiri_error_array_pusher(void * ctx, xmlErrorPtr error);
9
- NORETURN(void Nokogiri_error_raise(void * ctx, xmlErrorPtr error));
20
+ void Nokogiri_error_array_pusher(void *ctx, xmlErrorPtr error);
21
+ NORETURN(void Nokogiri_error_raise(void *ctx, xmlErrorPtr error));
10
22
 
11
23
  extern VALUE cNokogiriXmlSyntaxError;
12
- #endif
13
24
 
25
+ #endif /* NOKOGIRI_XML_SYNTAX_ERROR */
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Nokogiri
3
3
  # The version of Nokogiri you are using
4
- VERSION = "1.11.0"
4
+ VERSION = "1.11.1"
5
5
  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.11.0
4
+ version: 1.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Dalessio
@@ -17,7 +17,7 @@ authors:
17
17
  autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
- date: 2021-01-04 00:00:00.000000000 Z
20
+ date: 2021-01-06 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: racc
@@ -179,14 +179,14 @@ dependencies:
179
179
  requirements:
180
180
  - - "~>"
181
181
  - !ruby/object:Gem::Version
182
- version: '0.88'
182
+ version: '1.7'
183
183
  type: :development
184
184
  prerelease: false
185
185
  version_requirements: !ruby/object:Gem::Requirement
186
186
  requirements:
187
187
  - - "~>"
188
188
  - !ruby/object:Gem::Version
189
- version: '0.88'
189
+ version: '1.7'
190
190
  - !ruby/object:Gem::Dependency
191
191
  name: simplecov
192
192
  requirement: !ruby/object:Gem::Requirement
@@ -252,6 +252,7 @@ extra_rdoc_files:
252
252
  - ext/nokogiri/html_sax_push_parser.c
253
253
  - ext/nokogiri/xml_relax_ng.c
254
254
  - ext/nokogiri/xml_entity_decl.c
255
+ - ext/nokogiri/test_global_handlers.c
255
256
  - ext/nokogiri/xml_node.c
256
257
  - ext/nokogiri/xml_entity_reference.c
257
258
  - ext/nokogiri/xslt_stylesheet.c
@@ -281,6 +282,7 @@ files:
281
282
  - ext/nokogiri/html_sax_push_parser.h
282
283
  - ext/nokogiri/nokogiri.c
283
284
  - ext/nokogiri/nokogiri.h
285
+ - ext/nokogiri/test_global_handlers.c
284
286
  - ext/nokogiri/xml_attr.c
285
287
  - ext/nokogiri/xml_attr.h
286
288
  - ext/nokogiri/xml_attribute_decl.c