nokogiri 1.10.3 → 1.11.4

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 (159) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/LICENSE-DEPENDENCIES.md +1015 -947
  4. data/LICENSE.md +1 -1
  5. data/README.md +173 -94
  6. data/dependencies.yml +28 -26
  7. data/ext/nokogiri/depend +37 -358
  8. data/ext/nokogiri/extconf.rb +611 -391
  9. data/ext/nokogiri/html_document.c +78 -82
  10. data/ext/nokogiri/html_element_description.c +84 -71
  11. data/ext/nokogiri/html_entity_lookup.c +21 -16
  12. data/ext/nokogiri/html_sax_parser_context.c +69 -66
  13. data/ext/nokogiri/html_sax_push_parser.c +42 -34
  14. data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
  15. data/ext/nokogiri/nokogiri.c +192 -87
  16. data/ext/nokogiri/nokogiri.h +181 -89
  17. data/ext/nokogiri/test_global_handlers.c +40 -0
  18. data/ext/nokogiri/xml_attr.c +15 -15
  19. data/ext/nokogiri/xml_attribute_decl.c +18 -18
  20. data/ext/nokogiri/xml_cdata.c +13 -18
  21. data/ext/nokogiri/xml_comment.c +19 -26
  22. data/ext/nokogiri/xml_document.c +255 -183
  23. data/ext/nokogiri/xml_document_fragment.c +13 -15
  24. data/ext/nokogiri/xml_dtd.c +54 -48
  25. data/ext/nokogiri/xml_element_content.c +30 -27
  26. data/ext/nokogiri/xml_element_decl.c +22 -22
  27. data/ext/nokogiri/xml_encoding_handler.c +17 -11
  28. data/ext/nokogiri/xml_entity_decl.c +32 -30
  29. data/ext/nokogiri/xml_entity_reference.c +16 -18
  30. data/ext/nokogiri/xml_namespace.c +56 -49
  31. data/ext/nokogiri/xml_node.c +387 -316
  32. data/ext/nokogiri/xml_node_set.c +168 -156
  33. data/ext/nokogiri/xml_processing_instruction.c +17 -19
  34. data/ext/nokogiri/xml_reader.c +195 -172
  35. data/ext/nokogiri/xml_relax_ng.c +52 -28
  36. data/ext/nokogiri/xml_sax_parser.c +118 -118
  37. data/ext/nokogiri/xml_sax_parser_context.c +103 -86
  38. data/ext/nokogiri/xml_sax_push_parser.c +36 -27
  39. data/ext/nokogiri/xml_schema.c +111 -34
  40. data/ext/nokogiri/xml_syntax_error.c +42 -21
  41. data/ext/nokogiri/xml_text.c +13 -17
  42. data/ext/nokogiri/xml_xpath_context.c +206 -123
  43. data/ext/nokogiri/xslt_stylesheet.c +158 -165
  44. data/lib/nokogiri/css/node.rb +1 -0
  45. data/lib/nokogiri/css/parser.rb +63 -62
  46. data/lib/nokogiri/css/parser.y +2 -2
  47. data/lib/nokogiri/css/parser_extras.rb +39 -36
  48. data/lib/nokogiri/css/syntax_error.rb +1 -0
  49. data/lib/nokogiri/css/tokenizer.rb +105 -103
  50. data/lib/nokogiri/css/xpath_visitor.rb +73 -43
  51. data/lib/nokogiri/css.rb +1 -0
  52. data/lib/nokogiri/decorators/slop.rb +1 -0
  53. data/lib/nokogiri/extension.rb +26 -0
  54. data/lib/nokogiri/html/builder.rb +1 -0
  55. data/lib/nokogiri/html/document.rb +13 -26
  56. data/lib/nokogiri/html/document_fragment.rb +16 -15
  57. data/lib/nokogiri/html/element_description.rb +1 -0
  58. data/lib/nokogiri/html/element_description_defaults.rb +1 -0
  59. data/lib/nokogiri/html/entity_lookup.rb +1 -0
  60. data/lib/nokogiri/html/sax/parser.rb +1 -0
  61. data/lib/nokogiri/html/sax/parser_context.rb +1 -0
  62. data/lib/nokogiri/html/sax/push_parser.rb +1 -0
  63. data/lib/nokogiri/html.rb +1 -0
  64. data/lib/nokogiri/jruby/dependencies.rb +20 -0
  65. data/lib/nokogiri/syntax_error.rb +1 -0
  66. data/lib/nokogiri/version/constant.rb +5 -0
  67. data/lib/nokogiri/version/info.rb +205 -0
  68. data/lib/nokogiri/version.rb +3 -109
  69. data/lib/nokogiri/xml/attr.rb +1 -0
  70. data/lib/nokogiri/xml/attribute_decl.rb +1 -0
  71. data/lib/nokogiri/xml/builder.rb +36 -32
  72. data/lib/nokogiri/xml/cdata.rb +1 -0
  73. data/lib/nokogiri/xml/character_data.rb +1 -0
  74. data/lib/nokogiri/xml/document.rb +92 -41
  75. data/lib/nokogiri/xml/document_fragment.rb +5 -6
  76. data/lib/nokogiri/xml/dtd.rb +1 -0
  77. data/lib/nokogiri/xml/element_content.rb +1 -0
  78. data/lib/nokogiri/xml/element_decl.rb +1 -0
  79. data/lib/nokogiri/xml/entity_decl.rb +1 -0
  80. data/lib/nokogiri/xml/entity_reference.rb +1 -0
  81. data/lib/nokogiri/xml/namespace.rb +1 -0
  82. data/lib/nokogiri/xml/node/save_options.rb +1 -0
  83. data/lib/nokogiri/xml/node.rb +625 -290
  84. data/lib/nokogiri/xml/node_set.rb +1 -0
  85. data/lib/nokogiri/xml/notation.rb +1 -0
  86. data/lib/nokogiri/xml/parse_options.rb +10 -3
  87. data/lib/nokogiri/xml/pp/character_data.rb +1 -0
  88. data/lib/nokogiri/xml/pp/node.rb +1 -0
  89. data/lib/nokogiri/xml/pp.rb +1 -0
  90. data/lib/nokogiri/xml/processing_instruction.rb +1 -0
  91. data/lib/nokogiri/xml/reader.rb +9 -12
  92. data/lib/nokogiri/xml/relax_ng.rb +7 -2
  93. data/lib/nokogiri/xml/sax/document.rb +1 -0
  94. data/lib/nokogiri/xml/sax/parser.rb +1 -0
  95. data/lib/nokogiri/xml/sax/parser_context.rb +1 -0
  96. data/lib/nokogiri/xml/sax/push_parser.rb +1 -0
  97. data/lib/nokogiri/xml/sax.rb +1 -0
  98. data/lib/nokogiri/xml/schema.rb +13 -4
  99. data/lib/nokogiri/xml/searchable.rb +25 -16
  100. data/lib/nokogiri/xml/syntax_error.rb +1 -0
  101. data/lib/nokogiri/xml/text.rb +1 -0
  102. data/lib/nokogiri/xml/xpath/syntax_error.rb +2 -1
  103. data/lib/nokogiri/xml/xpath.rb +2 -3
  104. data/lib/nokogiri/xml/xpath_context.rb +1 -0
  105. data/lib/nokogiri/xml.rb +1 -0
  106. data/lib/nokogiri/xslt/stylesheet.rb +1 -0
  107. data/lib/nokogiri/xslt.rb +1 -0
  108. data/lib/nokogiri.rb +6 -27
  109. data/lib/xsd/xmlparser/nokogiri.rb +1 -0
  110. data/patches/libxml2/{0002-Remove-script-macro-support.patch → 0001-Remove-script-macro-support.patch} +0 -0
  111. data/patches/libxml2/{0003-Update-entities-to-remove-handling-of-ssi.patch → 0002-Update-entities-to-remove-handling-of-ssi.patch} +0 -0
  112. data/patches/libxml2/0003-libxml2.la-is-in-top_builddir.patch +25 -0
  113. data/patches/libxml2/0004-use-glibc-strlen.patch +53 -0
  114. data/patches/libxml2/0005-avoid-isnan-isinf.patch +81 -0
  115. data/patches/libxml2/0006-update-automake-files-for-arm64.patch +2511 -0
  116. data/patches/libxslt/0001-update-automake-files-for-arm64.patch +2511 -0
  117. data/patches/libxslt/0002-Fix-xml2-config-check-in-configure-script.patch +19 -0
  118. data/ports/archives/libxml2-2.9.12.tar.gz +0 -0
  119. data/ports/archives/libxslt-1.1.34.tar.gz +0 -0
  120. metadata +102 -147
  121. data/ext/nokogiri/html_document.h +0 -10
  122. data/ext/nokogiri/html_element_description.h +0 -10
  123. data/ext/nokogiri/html_entity_lookup.h +0 -8
  124. data/ext/nokogiri/html_sax_parser_context.h +0 -11
  125. data/ext/nokogiri/html_sax_push_parser.h +0 -9
  126. data/ext/nokogiri/xml_attr.h +0 -9
  127. data/ext/nokogiri/xml_attribute_decl.h +0 -9
  128. data/ext/nokogiri/xml_cdata.h +0 -9
  129. data/ext/nokogiri/xml_comment.h +0 -9
  130. data/ext/nokogiri/xml_document.h +0 -23
  131. data/ext/nokogiri/xml_document_fragment.h +0 -10
  132. data/ext/nokogiri/xml_dtd.h +0 -10
  133. data/ext/nokogiri/xml_element_content.h +0 -10
  134. data/ext/nokogiri/xml_element_decl.h +0 -9
  135. data/ext/nokogiri/xml_encoding_handler.h +0 -8
  136. data/ext/nokogiri/xml_entity_decl.h +0 -10
  137. data/ext/nokogiri/xml_entity_reference.h +0 -9
  138. data/ext/nokogiri/xml_io.c +0 -61
  139. data/ext/nokogiri/xml_io.h +0 -11
  140. data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
  141. data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
  142. data/ext/nokogiri/xml_namespace.h +0 -14
  143. data/ext/nokogiri/xml_node.h +0 -13
  144. data/ext/nokogiri/xml_node_set.h +0 -12
  145. data/ext/nokogiri/xml_processing_instruction.h +0 -9
  146. data/ext/nokogiri/xml_reader.h +0 -10
  147. data/ext/nokogiri/xml_relax_ng.h +0 -9
  148. data/ext/nokogiri/xml_sax_parser.h +0 -39
  149. data/ext/nokogiri/xml_sax_parser_context.h +0 -10
  150. data/ext/nokogiri/xml_sax_push_parser.h +0 -9
  151. data/ext/nokogiri/xml_schema.h +0 -9
  152. data/ext/nokogiri/xml_syntax_error.h +0 -13
  153. data/ext/nokogiri/xml_text.h +0 -9
  154. data/ext/nokogiri/xml_xpath_context.h +0 -10
  155. data/ext/nokogiri/xslt_stylesheet.h +0 -14
  156. data/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch +0 -78
  157. data/patches/libxslt/0001-Fix-security-framework-bypass.patch +0 -120
  158. data/ports/archives/libxml2-2.9.9.tar.gz +0 -0
  159. data/ports/archives/libxslt-1.1.33.tar.gz +0 -0
@@ -1,4 +1,6 @@
1
- #include <xml_attr.h>
1
+ #include <nokogiri.h>
2
+
3
+ VALUE cNokogiriXmlAttr;
2
4
 
3
5
  /*
4
6
  * call-seq:
@@ -7,7 +9,8 @@
7
9
  * Set the value for this Attr to +content+. Use `nil` to remove the value
8
10
  * (e.g., a HTML boolean attribute).
9
11
  */
10
- static VALUE set_value(VALUE self, VALUE content)
12
+ static VALUE
13
+ set_value(VALUE self, VALUE content)
11
14
  {
12
15
  xmlAttrPtr attr;
13
16
  xmlChar *value;
@@ -49,7 +52,8 @@ static VALUE set_value(VALUE self, VALUE content)
49
52
  *
50
53
  * Create a new Attr element on the +document+ with +name+
51
54
  */
52
- static VALUE new(int argc, VALUE *argv, VALUE klass)
55
+ static VALUE
56
+ new (int argc, VALUE *argv, VALUE klass)
53
57
  {
54
58
  xmlDocPtr xml_doc;
55
59
  VALUE document;
@@ -72,9 +76,9 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
72
76
  NULL
73
77
  );
74
78
 
75
- nokogiri_root_node((xmlNodePtr)node);
79
+ noko_xml_document_pin_node((xmlNodePtr)node);
76
80
 
77
- rb_node = Nokogiri_wrap_xml_node(klass, (xmlNodePtr)node);
81
+ rb_node = noko_xml_node_wrap(klass, (xmlNodePtr)node);
78
82
  rb_obj_call_init(rb_node, argc, argv);
79
83
 
80
84
  if (rb_block_given_p()) {
@@ -84,20 +88,16 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
84
88
  return rb_node;
85
89
  }
86
90
 
87
- VALUE cNokogiriXmlAttr;
88
- void init_xml_attr()
91
+ void
92
+ noko_init_xml_attr()
89
93
  {
90
- VALUE nokogiri = rb_define_module("Nokogiri");
91
- VALUE xml = rb_define_module_under(nokogiri, "XML");
92
- VALUE node = rb_define_class_under(xml, "Node", rb_cObject);
93
-
94
+ assert(cNokogiriXmlNode);
94
95
  /*
95
96
  * Attr represents a Attr node in an xml document.
96
97
  */
97
- VALUE klass = rb_define_class_under(xml, "Attr", node);
98
+ cNokogiriXmlAttr = rb_define_class_under(mNokogiriXml, "Attr", cNokogiriXmlNode);
98
99
 
99
- cNokogiriXmlAttr = klass;
100
+ rb_define_singleton_method(cNokogiriXmlAttr, "new", new, -1);
100
101
 
101
- rb_define_singleton_method(klass, "new", new, -1);
102
- rb_define_method(klass, "value=", set_value, 1);
102
+ rb_define_method(cNokogiriXmlAttr, "value=", set_value, 1);
103
103
  }
@@ -1,4 +1,6 @@
1
- #include <xml_attribute_decl.h>
1
+ #include <nokogiri.h>
2
+
3
+ VALUE cNokogiriXmlAttributeDecl;
2
4
 
3
5
  /*
4
6
  * call-seq:
@@ -6,7 +8,8 @@
6
8
  *
7
9
  * The attribute_type for this AttributeDecl
8
10
  */
9
- static VALUE attribute_type(VALUE self)
11
+ static VALUE
12
+ attribute_type(VALUE self)
10
13
  {
11
14
  xmlAttributePtr node;
12
15
  Data_Get_Struct(self, xmlAttribute, node);
@@ -19,12 +22,13 @@ static VALUE attribute_type(VALUE self)
19
22
  *
20
23
  * The default value
21
24
  */
22
- static VALUE default_value(VALUE self)
25
+ static VALUE
26
+ default_value(VALUE self)
23
27
  {
24
28
  xmlAttributePtr node;
25
29
  Data_Get_Struct(self, xmlAttribute, node);
26
30
 
27
- if(node->defaultValue) return NOKOGIRI_STR_NEW2(node->defaultValue);
31
+ if (node->defaultValue) { return NOKOGIRI_STR_NEW2(node->defaultValue); }
28
32
  return Qnil;
29
33
  }
30
34
 
@@ -34,7 +38,8 @@ static VALUE default_value(VALUE self)
34
38
  *
35
39
  * An enumeration of possible values
36
40
  */
37
- static VALUE enumeration(VALUE self)
41
+ static VALUE
42
+ enumeration(VALUE self)
38
43
  {
39
44
  xmlAttributePtr node;
40
45
  xmlEnumerationPtr enm;
@@ -45,7 +50,7 @@ static VALUE enumeration(VALUE self)
45
50
  list = rb_ary_new();
46
51
  enm = node->tree;
47
52
 
48
- while(enm) {
53
+ while (enm) {
49
54
  rb_ary_push(list, NOKOGIRI_STR_NEW2(enm->name));
50
55
  enm = enm->next;
51
56
  }
@@ -53,18 +58,13 @@ static VALUE enumeration(VALUE self)
53
58
  return list;
54
59
  }
55
60
 
56
- VALUE cNokogiriXmlAttributeDecl;
57
-
58
- void init_xml_attribute_decl()
61
+ void
62
+ noko_init_xml_attribute_decl()
59
63
  {
60
- VALUE nokogiri = rb_define_module("Nokogiri");
61
- VALUE xml = rb_define_module_under(nokogiri, "XML");
62
- VALUE node = rb_define_class_under(xml, "Node", rb_cObject);
63
- VALUE klass = rb_define_class_under(xml, "AttributeDecl", node);
64
-
65
- cNokogiriXmlAttributeDecl = klass;
64
+ assert(cNokogiriXmlNode);
65
+ cNokogiriXmlAttributeDecl = rb_define_class_under(mNokogiriXml, "AttributeDecl", cNokogiriXmlNode);
66
66
 
67
- rb_define_method(klass, "attribute_type", attribute_type, 0);
68
- rb_define_method(klass, "default", default_value, 0);
69
- rb_define_method(klass, "enumeration", enumeration, 0);
67
+ rb_define_method(cNokogiriXmlAttributeDecl, "attribute_type", attribute_type, 0);
68
+ rb_define_method(cNokogiriXmlAttributeDecl, "default", default_value, 0);
69
+ rb_define_method(cNokogiriXmlAttributeDecl, "enumeration", enumeration, 0);
70
70
  }
@@ -1,4 +1,6 @@
1
- #include <xml_cdata.h>
1
+ #include <nokogiri.h>
2
+
3
+ VALUE cNokogiriXmlCData;
2
4
 
3
5
  /*
4
6
  * call-seq:
@@ -9,7 +11,8 @@
9
11
  * If +content+ cannot be implicitly converted to a string, this method will
10
12
  * raise a TypeError exception.
11
13
  */
12
- static VALUE new(int argc, VALUE *argv, VALUE klass)
14
+ static VALUE
15
+ new (int argc, VALUE *argv, VALUE klass)
13
16
  {
14
17
  xmlDocPtr xml_doc;
15
18
  xmlNodePtr node;
@@ -31,32 +34,24 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
31
34
 
32
35
  node = xmlNewCDataBlock(xml_doc->doc, content_str, content_str_len);
33
36
 
34
- nokogiri_root_node(node);
37
+ noko_xml_document_pin_node(node);
35
38
 
36
- rb_node = Nokogiri_wrap_xml_node(klass, node);
39
+ rb_node = noko_xml_node_wrap(klass, node);
37
40
  rb_obj_call_init(rb_node, argc, argv);
38
41
 
39
- if(rb_block_given_p()) { rb_yield(rb_node); }
42
+ if (rb_block_given_p()) { rb_yield(rb_node); }
40
43
 
41
44
  return rb_node;
42
45
  }
43
46
 
44
- VALUE cNokogiriXmlCData;
45
- void init_xml_cdata()
47
+ void
48
+ noko_init_xml_cdata()
46
49
  {
47
- VALUE nokogiri = rb_define_module("Nokogiri");
48
- VALUE xml = rb_define_module_under(nokogiri, "XML");
49
- VALUE node = rb_define_class_under(xml, "Node", rb_cObject);
50
- VALUE char_data = rb_define_class_under(xml, "CharacterData", node);
51
- VALUE text = rb_define_class_under(xml, "Text", char_data);
52
-
50
+ assert(cNokogiriXmlText);
53
51
  /*
54
52
  * CData represents a CData node in an xml document.
55
53
  */
56
- VALUE klass = rb_define_class_under(xml, "CDATA", text);
57
-
58
-
59
- cNokogiriXmlCData = klass;
54
+ cNokogiriXmlCData = rb_define_class_under(mNokogiriXml, "CDATA", cNokogiriXmlText);
60
55
 
61
- rb_define_singleton_method(klass, "new", new, -1);
56
+ rb_define_singleton_method(cNokogiriXmlCData, "new", new, -1);
62
57
  }
@@ -1,4 +1,6 @@
1
- #include <xml_comment.h>
1
+ #include <nokogiri.h>
2
+
3
+ VALUE cNokogiriXmlComment;
2
4
 
3
5
  static ID document_id ;
4
6
 
@@ -9,7 +11,8 @@ static ID document_id ;
9
11
  * Create a new Comment element on the +document+ with +content+.
10
12
  * Alternatively, if a +node+ is passed, the +node+'s document is used.
11
13
  */
12
- static VALUE new(int argc, VALUE *argv, VALUE klass)
14
+ static VALUE
15
+ new (int argc, VALUE *argv, VALUE klass)
13
16
  {
14
17
  xmlDocPtr xml_doc;
15
18
  xmlNodePtr node;
@@ -20,50 +23,40 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
20
23
 
21
24
  rb_scan_args(argc, argv, "2*", &document, &content, &rest);
22
25
 
23
- if (rb_obj_is_kind_of(document, cNokogiriXmlNode))
24
- {
26
+ if (rb_obj_is_kind_of(document, cNokogiriXmlNode)) {
25
27
  document = rb_funcall(document, document_id, 0);
26
- }
27
- else if ( !rb_obj_is_kind_of(document, cNokogiriXmlDocument)
28
- && !rb_obj_is_kind_of(document, cNokogiriXmlDocumentFragment))
29
- {
28
+ } else if (!rb_obj_is_kind_of(document, cNokogiriXmlDocument)
29
+ && !rb_obj_is_kind_of(document, cNokogiriXmlDocumentFragment)) {
30
30
  rb_raise(rb_eArgError, "first argument must be a XML::Document or XML::Node");
31
31
  }
32
32
 
33
33
  Data_Get_Struct(document, xmlDoc, xml_doc);
34
34
 
35
35
  node = xmlNewDocComment(
36
- xml_doc,
37
- (const xmlChar *)StringValueCStr(content)
38
- );
36
+ xml_doc,
37
+ (const xmlChar *)StringValueCStr(content)
38
+ );
39
39
 
40
- rb_node = Nokogiri_wrap_xml_node(klass, node);
40
+ rb_node = noko_xml_node_wrap(klass, node);
41
41
  rb_obj_call_init(rb_node, argc, argv);
42
42
 
43
- nokogiri_root_node(node);
43
+ noko_xml_document_pin_node(node);
44
44
 
45
- if(rb_block_given_p()) rb_yield(rb_node);
45
+ if (rb_block_given_p()) { rb_yield(rb_node); }
46
46
 
47
47
  return rb_node;
48
48
  }
49
49
 
50
- VALUE cNokogiriXmlComment;
51
- void init_xml_comment()
50
+ void
51
+ noko_init_xml_comment()
52
52
  {
53
- VALUE nokogiri = rb_define_module("Nokogiri");
54
- VALUE xml = rb_define_module_under(nokogiri, "XML");
55
- VALUE node = rb_define_class_under(xml, "Node", rb_cObject);
56
- VALUE char_data = rb_define_class_under(xml, "CharacterData", node);
57
-
53
+ assert(cNokogiriXmlCharacterData);
58
54
  /*
59
55
  * Comment represents a comment node in an xml document.
60
56
  */
61
- VALUE klass = rb_define_class_under(xml, "Comment", char_data);
62
-
63
-
64
- cNokogiriXmlComment = klass;
57
+ cNokogiriXmlComment = rb_define_class_under(mNokogiriXml, "Comment", cNokogiriXmlCharacterData);
65
58
 
66
- rb_define_singleton_method(klass, "new", new, -1);
59
+ rb_define_singleton_method(cNokogiriXmlComment, "new", new, -1);
67
60
 
68
61
  document_id = rb_intern("document");
69
62
  }