nokogiri 1.14.5 → 1.15.0

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.

Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -8
  3. data/dependencies.yml +6 -6
  4. data/ext/nokogiri/extconf.rb +66 -22
  5. data/ext/nokogiri/html4_document.c +1 -2
  6. data/ext/nokogiri/html4_element_description.c +19 -14
  7. data/ext/nokogiri/html4_sax_parser_context.c +10 -16
  8. data/ext/nokogiri/html4_sax_push_parser.c +2 -2
  9. data/ext/nokogiri/nokogiri.c +46 -24
  10. data/ext/nokogiri/nokogiri.h +13 -2
  11. data/ext/nokogiri/xml_attr.c +1 -1
  12. data/ext/nokogiri/xml_cdata.c +10 -2
  13. data/ext/nokogiri/xml_comment.c +1 -1
  14. data/ext/nokogiri/xml_document.c +102 -22
  15. data/ext/nokogiri/xml_document_fragment.c +1 -1
  16. data/ext/nokogiri/xml_dtd.c +1 -1
  17. data/ext/nokogiri/xml_element_content.c +32 -29
  18. data/ext/nokogiri/xml_element_decl.c +5 -5
  19. data/ext/nokogiri/xml_encoding_handler.c +12 -4
  20. data/ext/nokogiri/xml_entity_reference.c +1 -1
  21. data/ext/nokogiri/xml_namespace.c +11 -12
  22. data/ext/nokogiri/xml_node.c +7 -7
  23. data/ext/nokogiri/xml_node_set.c +125 -105
  24. data/ext/nokogiri/xml_processing_instruction.c +1 -1
  25. data/ext/nokogiri/xml_reader.c +37 -28
  26. data/ext/nokogiri/xml_relax_ng.c +65 -78
  27. data/ext/nokogiri/xml_sax_parser.c +24 -5
  28. data/ext/nokogiri/xml_sax_parser_context.c +46 -25
  29. data/ext/nokogiri/xml_sax_push_parser.c +29 -8
  30. data/ext/nokogiri/xml_schema.c +90 -116
  31. data/ext/nokogiri/xml_text.c +10 -2
  32. data/ext/nokogiri/xml_xpath_context.c +156 -83
  33. data/ext/nokogiri/xslt_stylesheet.c +103 -50
  34. data/gumbo-parser/src/error.c +8 -4
  35. data/gumbo-parser/src/foreign_attrs.c +13 -14
  36. data/gumbo-parser/src/foreign_attrs.gperf +1 -1
  37. data/gumbo-parser/src/parser.c +13 -0
  38. data/lib/nokogiri/css/xpath_visitor.rb +2 -2
  39. data/lib/nokogiri/extension.rb +1 -1
  40. data/lib/nokogiri/html4/document_fragment.rb +1 -1
  41. data/lib/nokogiri/html4/element_description_defaults.rb +1821 -353
  42. data/lib/nokogiri/html5/document_fragment.rb +1 -1
  43. data/lib/nokogiri/html5/node.rb +5 -0
  44. data/lib/nokogiri/html5.rb +5 -2
  45. data/lib/nokogiri/jruby/nokogiri_jars.rb +3 -3
  46. data/lib/nokogiri/version/constant.rb +1 -1
  47. data/lib/nokogiri/xml/attribute_decl.rb +4 -2
  48. data/lib/nokogiri/xml/document_fragment.rb +1 -1
  49. data/lib/nokogiri/xml/element_content.rb +10 -2
  50. data/lib/nokogiri/xml/element_decl.rb +4 -2
  51. data/lib/nokogiri/xml/entity_decl.rb +4 -2
  52. data/lib/nokogiri/xml/node/save_options.rb +8 -0
  53. data/lib/nokogiri/xml/node.rb +22 -13
  54. data/lib/nokogiri/xml/pp/node.rb +23 -12
  55. data/lib/nokogiri/xml/sax/document.rb +1 -1
  56. data/lib/nokogiri/xml/searchable.rb +18 -10
  57. data/lib/nokogiri/xslt.rb +73 -3
  58. data/lib/nokogiri.rb +12 -4
  59. data/lib/xsd/xmlparser/nokogiri.rb +1 -1
  60. data/patches/libxml2/0010-update-config.guess-and-config.sub-for-libxml2.patch +224 -0
  61. data/patches/libxml2/0011-rip-out-libxml2-s-libc_single_threaded-support.patch +30 -0
  62. data/patches/libxslt/0001-update-config.guess-and-config.sub-for-libxslt.patch +224 -0
  63. data/ports/archives/libxml2-2.11.3.tar.xz +0 -0
  64. data/ports/archives/libxslt-1.1.38.tar.xz +0 -0
  65. metadata +9 -7
  66. data/patches/libxslt/0001-update-automake-files-for-arm64.patch +0 -3037
  67. data/ports/archives/libxml2-2.10.4.tar.xz +0 -0
  68. data/ports/archives/libxslt-1.1.37.tar.xz +0 -0
@@ -3,19 +3,30 @@
3
3
  VALUE cNokogiriXsltStylesheet ;
4
4
 
5
5
  static void
6
- mark(nokogiriXsltStylesheetTuple *wrapper)
6
+ mark(void *data)
7
7
  {
8
+ nokogiriXsltStylesheetTuple *wrapper = (nokogiriXsltStylesheetTuple *)data;
8
9
  rb_gc_mark(wrapper->func_instances);
9
10
  }
10
11
 
11
12
  static void
12
- dealloc(nokogiriXsltStylesheetTuple *wrapper)
13
+ dealloc(void *data)
13
14
  {
15
+ nokogiriXsltStylesheetTuple *wrapper = (nokogiriXsltStylesheetTuple *)data;
14
16
  xsltStylesheetPtr doc = wrapper->ss;
15
17
  xsltFreeStylesheet(doc);
16
18
  ruby_xfree(wrapper);
17
19
  }
18
20
 
21
+ static const rb_data_type_t xslt_stylesheet_type = {
22
+ .wrap_struct_name = "Nokogiri::XSLT::Stylesheet",
23
+ .function = {
24
+ .dmark = mark,
25
+ .dfree = dealloc,
26
+ },
27
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY
28
+ };
29
+
19
30
  PRINTFLIKE_DECL(2, 3)
20
31
  static void
21
32
  xslt_generic_error_handler(void *ctx, const char *msg, ...)
@@ -42,8 +53,12 @@ Nokogiri_wrap_xslt_stylesheet(xsltStylesheetPtr ss)
42
53
  VALUE self;
43
54
  nokogiriXsltStylesheetTuple *wrapper;
44
55
 
45
- self = Data_Make_Struct(cNokogiriXsltStylesheet, nokogiriXsltStylesheetTuple,
46
- mark, dealloc, wrapper);
56
+ self = TypedData_Make_Struct(
57
+ cNokogiriXsltStylesheet,
58
+ nokogiriXsltStylesheetTuple,
59
+ &xslt_stylesheet_type,
60
+ wrapper
61
+ );
47
62
 
48
63
  ss->_private = (void *)self;
49
64
  wrapper->ss = ss;
@@ -64,7 +79,8 @@ parse_stylesheet_doc(VALUE klass, VALUE xmldocobj)
64
79
  xmlDocPtr xml, xml_cpy;
65
80
  VALUE errstr, exception;
66
81
  xsltStylesheetPtr ss ;
67
- Data_Get_Struct(xmldocobj, xmlDoc, xml);
82
+
83
+ xml = noko_xml_document_unwrap(xmldocobj);
68
84
 
69
85
  errstr = rb_str_new(0, 0);
70
86
  xsltSetGenericErrorFunc((void *)errstr, xslt_generic_error_handler);
@@ -91,7 +107,7 @@ parse_stylesheet_doc(VALUE klass, VALUE xmldocobj)
91
107
  * Serialize +document+ to an xml string.
92
108
  */
93
109
  static VALUE
94
- serialize(VALUE self, VALUE xmlobj)
110
+ rb_xslt_stylesheet_serialize(VALUE self, VALUE xmlobj)
95
111
  {
96
112
  xmlDocPtr xml ;
97
113
  nokogiriXsltStylesheetTuple *wrapper;
@@ -99,8 +115,13 @@ serialize(VALUE self, VALUE xmlobj)
99
115
  int doc_len ;
100
116
  VALUE rval ;
101
117
 
102
- Data_Get_Struct(xmlobj, xmlDoc, xml);
103
- Data_Get_Struct(self, nokogiriXsltStylesheetTuple, wrapper);
118
+ xml = noko_xml_document_unwrap(xmlobj);
119
+ TypedData_Get_Struct(
120
+ self,
121
+ nokogiriXsltStylesheetTuple,
122
+ &xslt_stylesheet_type,
123
+ wrapper
124
+ );
104
125
  xsltSaveResultToString(&doc_ptr, &doc_len, xml, wrapper->ss);
105
126
  rval = NOKOGIRI_STR_NEW(doc_ptr, doc_len);
106
127
  xmlFree(doc_ptr);
@@ -221,60 +242,74 @@ serialize(VALUE self, VALUE xmlobj)
221
242
  * See: Nokogiri::XSLT.quote_params
222
243
  */
223
244
  static VALUE
224
- transform(int argc, VALUE *argv, VALUE self)
245
+ rb_xslt_stylesheet_transform(int argc, VALUE *argv, VALUE self)
225
246
  {
226
- VALUE xmldoc, paramobj, errstr, exception ;
227
- xmlDocPtr xml ;
228
- xmlDocPtr result ;
247
+ VALUE rb_document, rb_param, rb_error_str;
248
+ xmlDocPtr c_document ;
249
+ xmlDocPtr c_result_document ;
229
250
  nokogiriXsltStylesheetTuple *wrapper;
230
251
  const char **params ;
231
252
  long param_len, j ;
232
253
  int parse_error_occurred ;
254
+ int defensive_copy_p = 0;
233
255
 
234
- rb_scan_args(argc, argv, "11", &xmldoc, &paramobj);
235
- if (NIL_P(paramobj)) { paramobj = rb_ary_new2(0L) ; }
236
- if (!rb_obj_is_kind_of(xmldoc, cNokogiriXmlDocument)) {
256
+ rb_scan_args(argc, argv, "11", &rb_document, &rb_param);
257
+ if (NIL_P(rb_param)) { rb_param = rb_ary_new2(0L) ; }
258
+ if (!rb_obj_is_kind_of(rb_document, cNokogiriXmlDocument)) {
237
259
  rb_raise(rb_eArgError, "argument must be a Nokogiri::XML::Document");
238
260
  }
239
261
 
240
262
  /* handle hashes as arguments. */
241
- if (T_HASH == TYPE(paramobj)) {
242
- paramobj = rb_funcall(paramobj, rb_intern("to_a"), 0);
243
- paramobj = rb_funcall(paramobj, rb_intern("flatten"), 0);
263
+ if (T_HASH == TYPE(rb_param)) {
264
+ rb_param = rb_funcall(rb_param, rb_intern("to_a"), 0);
265
+ rb_param = rb_funcall(rb_param, rb_intern("flatten"), 0);
244
266
  }
245
267
 
246
- Check_Type(paramobj, T_ARRAY);
268
+ Check_Type(rb_param, T_ARRAY);
247
269
 
248
- Data_Get_Struct(xmldoc, xmlDoc, xml);
249
- Data_Get_Struct(self, nokogiriXsltStylesheetTuple, wrapper);
270
+ c_document = noko_xml_document_unwrap(rb_document);
271
+ TypedData_Get_Struct(self, nokogiriXsltStylesheetTuple, &xslt_stylesheet_type, wrapper);
250
272
 
251
- param_len = RARRAY_LEN(paramobj);
273
+ param_len = RARRAY_LEN(rb_param);
252
274
  params = ruby_xcalloc((size_t)param_len + 1, sizeof(char *));
253
275
  for (j = 0 ; j < param_len ; j++) {
254
- VALUE entry = rb_ary_entry(paramobj, j);
276
+ VALUE entry = rb_ary_entry(rb_param, j);
255
277
  const char *ptr = StringValueCStr(entry);
256
278
  params[j] = ptr;
257
279
  }
258
280
  params[param_len] = 0 ;
259
281
 
260
- errstr = rb_str_new(0, 0);
261
- xsltSetGenericErrorFunc((void *)errstr, xslt_generic_error_handler);
262
- xmlSetGenericErrorFunc((void *)errstr, xslt_generic_error_handler);
282
+ xsltTransformContextPtr c_transform_context = xsltNewTransformContext(wrapper->ss, c_document);
283
+ if (xsltNeedElemSpaceHandling(c_transform_context) &&
284
+ noko_xml_document_has_wrapped_blank_nodes_p(c_document)) {
285
+ // see https://github.com/sparklemotion/nokogiri/issues/2800
286
+ c_document = xmlCopyDoc(c_document, 1);
287
+ defensive_copy_p = 1;
288
+ }
289
+ xsltFreeTransformContext(c_transform_context);
290
+
291
+ rb_error_str = rb_str_new(0, 0);
292
+ xsltSetGenericErrorFunc((void *)rb_error_str, xslt_generic_error_handler);
293
+ xmlSetGenericErrorFunc((void *)rb_error_str, xslt_generic_error_handler);
294
+
295
+ c_result_document = xsltApplyStylesheet(wrapper->ss, c_document, params);
263
296
 
264
- result = xsltApplyStylesheet(wrapper->ss, xml, params);
265
297
  ruby_xfree(params);
298
+ if (defensive_copy_p) {
299
+ xmlFreeDoc(c_document);
300
+ c_document = NULL;
301
+ }
266
302
 
267
303
  xsltSetGenericErrorFunc(NULL, NULL);
268
304
  xmlSetGenericErrorFunc(NULL, NULL);
269
305
 
270
- parse_error_occurred = (Qfalse == rb_funcall(errstr, rb_intern("empty?"), 0));
306
+ parse_error_occurred = (Qfalse == rb_funcall(rb_error_str, rb_intern("empty?"), 0));
271
307
 
272
308
  if (parse_error_occurred) {
273
- exception = rb_exc_new3(rb_eRuntimeError, errstr);
274
- rb_exc_raise(exception);
309
+ rb_exc_raise(rb_exc_new3(rb_eRuntimeError, rb_error_str));
275
310
  }
276
311
 
277
- return noko_xml_document_wrap((VALUE)0, result) ;
312
+ return noko_xml_document_wrap((VALUE)0, c_result_document) ;
278
313
  }
279
314
 
280
315
  static void
@@ -290,7 +325,12 @@ method_caller(xmlXPathParserContextPtr ctxt, int nargs)
290
325
  handler = (VALUE)xsltGetExtData(transform, functionURI);
291
326
  function_name = (const char *)(ctxt->context->function);
292
327
 
293
- Nokogiri_marshal_xpath_funcall_and_return_values(ctxt, nargs, handler, (const char *)function_name);
328
+ Nokogiri_marshal_xpath_funcall_and_return_values(
329
+ ctxt,
330
+ nargs,
331
+ handler,
332
+ (const char *)function_name
333
+ );
294
334
  }
295
335
 
296
336
  static void *
@@ -306,12 +346,20 @@ initFunc(xsltTransformContextPtr ctxt, const xmlChar *uri)
306
346
 
307
347
  for (i = 0; i < RARRAY_LEN(methods); i++) {
308
348
  VALUE method_name = rb_obj_as_string(rb_ary_entry(methods, i));
309
- xsltRegisterExtFunction(ctxt,
310
- (unsigned char *)StringValueCStr(method_name), uri, method_caller);
349
+ xsltRegisterExtFunction(
350
+ ctxt,
351
+ (unsigned char *)StringValueCStr(method_name),
352
+ uri,
353
+ method_caller
354
+ );
311
355
  }
312
356
 
313
- Data_Get_Struct((VALUE)ctxt->style->_private, nokogiriXsltStylesheetTuple,
314
- wrapper);
357
+ TypedData_Get_Struct(
358
+ (VALUE)ctxt->style->_private,
359
+ nokogiriXsltStylesheetTuple,
360
+ &xslt_stylesheet_type,
361
+ wrapper
362
+ );
315
363
  inst = rb_class_new_instance(0, NULL, obj);
316
364
  rb_ary_push(wrapper->func_instances, inst);
317
365
 
@@ -324,33 +372,38 @@ shutdownFunc(xsltTransformContextPtr ctxt,
324
372
  {
325
373
  nokogiriXsltStylesheetTuple *wrapper;
326
374
 
327
- Data_Get_Struct((VALUE)ctxt->style->_private, nokogiriXsltStylesheetTuple,
328
- wrapper);
375
+ TypedData_Get_Struct(
376
+ (VALUE)ctxt->style->_private,
377
+ nokogiriXsltStylesheetTuple,
378
+ &xslt_stylesheet_type,
379
+ wrapper
380
+ );
329
381
 
330
382
  rb_ary_clear(wrapper->func_instances);
331
383
  }
332
384
 
333
- /*
334
- * call-seq:
335
- * register(uri, custom_handler_class)
336
- *
337
- * Register a class that implements custom XSLT transformation functions.
338
- */
385
+ /* docstring is in lib/nokogiri/xslt.rb */
339
386
  static VALUE
340
- registr(VALUE self, VALUE uri, VALUE obj)
387
+ rb_xslt_s_register(VALUE self, VALUE uri, VALUE obj)
341
388
  {
342
389
  VALUE modules = rb_iv_get(self, "@modules");
343
- if (NIL_P(modules)) { rb_raise(rb_eRuntimeError, "wtf! @modules isn't set"); }
390
+ if (NIL_P(modules)) {
391
+ rb_raise(rb_eRuntimeError, "internal error: @modules not set");
392
+ }
344
393
 
345
394
  rb_hash_aset(modules, uri, obj);
346
- xsltRegisterExtModule((unsigned char *)StringValueCStr(uri), initFunc, shutdownFunc);
395
+ xsltRegisterExtModule(
396
+ (unsigned char *)StringValueCStr(uri),
397
+ initFunc,
398
+ shutdownFunc
399
+ );
347
400
  return self;
348
401
  }
349
402
 
350
403
  void
351
404
  noko_init_xslt_stylesheet(void)
352
405
  {
353
- rb_define_singleton_method(mNokogiriXslt, "register", registr, 2);
406
+ rb_define_singleton_method(mNokogiriXslt, "register", rb_xslt_s_register, 2);
354
407
  rb_iv_set(mNokogiriXslt, "@modules", rb_hash_new());
355
408
 
356
409
  cNokogiriXsltStylesheet = rb_define_class_under(mNokogiriXslt, "Stylesheet", rb_cObject);
@@ -358,6 +411,6 @@ noko_init_xslt_stylesheet(void)
358
411
  rb_undef_alloc_func(cNokogiriXsltStylesheet);
359
412
 
360
413
  rb_define_singleton_method(cNokogiriXsltStylesheet, "parse_stylesheet_doc", parse_stylesheet_doc, 1);
361
- rb_define_method(cNokogiriXsltStylesheet, "serialize", serialize, 1);
362
- rb_define_method(cNokogiriXsltStylesheet, "transform", transform, -1);
414
+ rb_define_method(cNokogiriXsltStylesheet, "serialize", rb_xslt_stylesheet_serialize, 1);
415
+ rb_define_method(cNokogiriXsltStylesheet, "transform", rb_xslt_stylesheet_transform, -1);
363
416
  }
@@ -91,7 +91,7 @@ static void print_tag_stack (
91
91
  const GumboParserError* error,
92
92
  GumboStringBuffer* output
93
93
  ) {
94
- print_message(output, " Currently open tags: ");
94
+ print_message(output, " Currently open tags: ");
95
95
  for (unsigned int i = 0; i < error->tag_stack.length; ++i) {
96
96
  if (i) {
97
97
  print_message(output, ", ");
@@ -347,15 +347,19 @@ static void handle_parser_error (
347
347
  if (error->parser_state == GUMBO_INSERTION_MODE_INITIAL) {
348
348
  print_message(output, "You must provide a doctype");
349
349
  } else {
350
- print_message(output, "Premature end of file");
350
+ print_message(output, "Premature end of file.");
351
351
  print_tag_stack(error, output);
352
352
  }
353
353
  return;
354
354
  case GUMBO_TOKEN_START_TAG:
355
+ print_message(output, "Start tag '%s' isn't allowed here.",
356
+ gumbo_normalized_tagname(error->input_tag));
357
+ print_tag_stack(error, output);
358
+ return;
355
359
  case GUMBO_TOKEN_END_TAG:
356
- print_message(output, "That tag isn't allowed here");
360
+ print_message(output, "Eng tag '%s' isn't allowed here.",
361
+ gumbo_normalized_tagname(error->input_tag));
357
362
  print_tag_stack(error, output);
358
- // TODO(jdtang): Give more specific messaging.
359
363
  return;
360
364
  }
361
365
  }
@@ -1,6 +1,6 @@
1
1
  /* ANSI-C code produced by gperf version 3.1 */
2
2
  /* Command-line: gperf -m100 -n src/foreign_attrs.gperf */
3
- /* Computed positions: -k'2,8' */
3
+ /* Computed positions: -k'8-9' */
4
4
  /* Filtered by: gperf-filter.sed */
5
5
 
6
6
  #include "replacement.h"
@@ -29,9 +29,9 @@ hash (register const char *str, register size_t len)
29
29
  11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
30
30
  11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
31
31
  11, 11, 11, 11, 11, 11, 11, 11, 11, 2,
32
- 11, 10, 11, 9, 7, 6, 11, 11, 1, 0,
33
- 11, 5, 11, 11, 4, 11, 11, 11, 11, 11,
34
- 11, 3, 11, 11, 11, 11, 11, 11, 11, 11,
32
+ 11, 1, 11, 10, 4, 4, 11, 11, 3, 11,
33
+ 11, 5, 3, 11, 0, 11, 2, 11, 11, 11,
34
+ 11, 2, 11, 11, 11, 11, 11, 11, 11, 11,
35
35
  11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
36
36
  11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
37
37
  11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
@@ -51,15 +51,14 @@ hash (register const char *str, register size_t len)
51
51
  switch (len)
52
52
  {
53
53
  default:
54
+ hval += asso_values[(unsigned char)str[8]];
55
+ /*FALLTHROUGH*/
56
+ case 8:
54
57
  hval += asso_values[(unsigned char)str[7]];
55
58
  /*FALLTHROUGH*/
56
59
  case 7:
57
60
  case 6:
58
61
  case 5:
59
- case 4:
60
- case 3:
61
- case 2:
62
- hval += asso_values[(unsigned char)str[1]];
63
62
  break;
64
63
  }
65
64
  return hval;
@@ -70,21 +69,21 @@ gumbo_get_foreign_attr_replacement (register const char *str, register size_t le
70
69
  {
71
70
  static const unsigned char lengthtable[] =
72
71
  {
73
- 5, 11, 9, 13, 10, 10, 10, 11, 10, 8, 8
72
+ 5, 10, 13, 9, 13, 10, 11, 11, 10, 10, 8
74
73
  };
75
74
  static const ForeignAttrReplacement wordlist[] =
76
75
  {
77
76
  {"xmlns", "xmlns", GUMBO_ATTR_NAMESPACE_XMLNS},
78
- {"xmlns:xlink", "xlink", GUMBO_ATTR_NAMESPACE_XMLNS},
77
+ {"xlink:href", "href", GUMBO_ATTR_NAMESPACE_XLINK},
78
+ {"xlink:arcrole", "arcrole", GUMBO_ATTR_NAMESPACE_XLINK},
79
79
  {"xml:space", "space", GUMBO_ATTR_NAMESPACE_XML},
80
80
  {"xlink:actuate", "actuate", GUMBO_ATTR_NAMESPACE_XLINK},
81
81
  {"xlink:type", "type", GUMBO_ATTR_NAMESPACE_XLINK},
82
- {"xlink:href", "href", GUMBO_ATTR_NAMESPACE_XLINK},
83
- {"xlink:role", "role", GUMBO_ATTR_NAMESPACE_XLINK},
84
82
  {"xlink:title", "title", GUMBO_ATTR_NAMESPACE_XLINK},
83
+ {"xmlns:xlink", "xlink", GUMBO_ATTR_NAMESPACE_XMLNS},
84
+ {"xlink:role", "role", GUMBO_ATTR_NAMESPACE_XLINK},
85
85
  {"xlink:show", "show", GUMBO_ATTR_NAMESPACE_XLINK},
86
- {"xml:lang", "lang", GUMBO_ATTR_NAMESPACE_XML},
87
- {"xml:base", "base", GUMBO_ATTR_NAMESPACE_XML}
86
+ {"xml:lang", "lang", GUMBO_ATTR_NAMESPACE_XML}
88
87
  };
89
88
 
90
89
  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@@ -15,12 +15,12 @@ ForeignAttrReplacement;
15
15
 
16
16
  %%
17
17
  "xlink:actuate", "actuate", GUMBO_ATTR_NAMESPACE_XLINK
18
+ "xlink:arcrole", "arcrole", GUMBO_ATTR_NAMESPACE_XLINK
18
19
  "xlink:href", "href", GUMBO_ATTR_NAMESPACE_XLINK
19
20
  "xlink:role", "role", GUMBO_ATTR_NAMESPACE_XLINK
20
21
  "xlink:show", "show", GUMBO_ATTR_NAMESPACE_XLINK
21
22
  "xlink:title", "title", GUMBO_ATTR_NAMESPACE_XLINK
22
23
  "xlink:type", "type", GUMBO_ATTR_NAMESPACE_XLINK
23
- "xml:base", "base", GUMBO_ATTR_NAMESPACE_XML
24
24
  "xml:lang", "lang", GUMBO_ATTR_NAMESPACE_XML
25
25
  "xml:space", "space", GUMBO_ATTR_NAMESPACE_XML
26
26
  "xmlns", "xmlns", GUMBO_ATTR_NAMESPACE_XMLNS
@@ -2678,6 +2678,7 @@ static void handle_in_head(GumboParser* parser, GumboToken* token) {
2678
2678
  static void handle_in_head_noscript(GumboParser* parser, GumboToken* token) {
2679
2679
  if (token->type == GUMBO_TOKEN_DOCTYPE) {
2680
2680
  parser_add_parse_error(parser, token);
2681
+ ignore_token(parser);
2681
2682
  return;
2682
2683
  }
2683
2684
  if (tag_is(token, kStartTag, GUMBO_TAG_HTML)) {
@@ -3963,6 +3964,18 @@ static void handle_in_select(GumboParser* parser, GumboToken* token) {
3963
3964
  insert_element_from_token(parser, token);
3964
3965
  return;
3965
3966
  }
3967
+ if (tag_is(token, kStartTag, GUMBO_TAG_HR)) {
3968
+ if (node_html_tag_is(get_current_node(parser), GUMBO_TAG_OPTION)) {
3969
+ pop_current_node(parser);
3970
+ }
3971
+ if (node_html_tag_is(get_current_node(parser), GUMBO_TAG_OPTGROUP)) {
3972
+ pop_current_node(parser);
3973
+ }
3974
+ insert_element_from_token(parser, token);
3975
+ pop_current_node(parser);
3976
+ acknowledge_self_closing_tag(parser);
3977
+ return;
3978
+ }
3966
3979
  if (tag_is(token, kEndTag, GUMBO_TAG_OPTGROUP)) {
3967
3980
  GumboVector* open_elements = &parser->_parser_state->_open_elements;
3968
3981
  if (
@@ -133,7 +133,7 @@ module Nokogiri
133
133
  args += node.value[1..-1].map do |n|
134
134
  n.is_a?(Nokogiri::CSS::Node) ? n.accept(self) : n
135
135
  end
136
- "#{node.value.first}#{args.join(",")})"
136
+ "nokogiri:#{node.value.first}#{args.join(",")})"
137
137
  end
138
138
  end
139
139
 
@@ -207,7 +207,7 @@ module Nokogiri
207
207
  when "parent" then "node()"
208
208
  when "root" then "not(parent::*)"
209
209
  else
210
- node.value.first + "(.)"
210
+ "nokogiri:#{node.value.first}(.)"
211
211
  end
212
212
  end
213
213
  end
@@ -6,7 +6,7 @@ begin
6
6
  RUBY_VERSION =~ /(\d+\.\d+)/
7
7
  require_relative "#{Regexp.last_match(1)}/nokogiri"
8
8
  rescue LoadError => e
9
- if /GLIBC/.match?(e.message)
9
+ if e.message.include?("GLIBC")
10
10
  warn(<<~EOM)
11
11
 
12
12
  ERROR: It looks like you're trying to use Nokogiri as a precompiled native gem on a system
@@ -24,7 +24,7 @@ module Nokogiri
24
24
  new(doc, tags, nil, options, &block)
25
25
  end
26
26
 
27
- def initialize(document, tags = nil, ctx = nil, options = XML::ParseOptions::DEFAULT_HTML)
27
+ def initialize(document, tags = nil, ctx = nil, options = XML::ParseOptions::DEFAULT_HTML) # rubocop:disable Lint/MissingSuper
28
28
  return self unless tags
29
29
 
30
30
  options = Nokogiri::XML::ParseOptions.new(options) if Integer === options