nokogiri 1.10.10-x86-mingw32 → 1.11.0-x86-mingw32

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 (164) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/LICENSE-DEPENDENCIES.md +1015 -947
  4. data/README.md +165 -91
  5. data/ext/nokogiri/depend +476 -357
  6. data/ext/nokogiri/extconf.rb +507 -357
  7. data/ext/nokogiri/html_document.c +79 -78
  8. data/ext/nokogiri/html_sax_parser_context.c +2 -2
  9. data/ext/nokogiri/include/libexslt/exslt.h +102 -0
  10. data/ext/nokogiri/include/libexslt/exsltconfig.h +70 -0
  11. data/ext/nokogiri/include/libexslt/exsltexports.h +140 -0
  12. data/ext/nokogiri/include/libxml2/libxml/DOCBparser.h +96 -0
  13. data/ext/nokogiri/include/libxml2/libxml/HTMLparser.h +306 -0
  14. data/ext/nokogiri/include/libxml2/libxml/HTMLtree.h +147 -0
  15. data/ext/nokogiri/include/libxml2/libxml/SAX.h +173 -0
  16. data/ext/nokogiri/include/libxml2/libxml/SAX2.h +178 -0
  17. data/ext/nokogiri/include/libxml2/libxml/c14n.h +126 -0
  18. data/ext/nokogiri/include/libxml2/libxml/catalog.h +182 -0
  19. data/ext/nokogiri/include/libxml2/libxml/chvalid.h +230 -0
  20. data/ext/nokogiri/include/libxml2/libxml/debugXML.h +217 -0
  21. data/ext/nokogiri/include/libxml2/libxml/dict.h +79 -0
  22. data/ext/nokogiri/include/libxml2/libxml/encoding.h +245 -0
  23. data/ext/nokogiri/include/libxml2/libxml/entities.h +151 -0
  24. data/ext/nokogiri/include/libxml2/libxml/globals.h +508 -0
  25. data/ext/nokogiri/include/libxml2/libxml/hash.h +236 -0
  26. data/ext/nokogiri/include/libxml2/libxml/list.h +137 -0
  27. data/ext/nokogiri/include/libxml2/libxml/nanoftp.h +163 -0
  28. data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +81 -0
  29. data/ext/nokogiri/include/libxml2/libxml/parser.h +1241 -0
  30. data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +644 -0
  31. data/ext/nokogiri/include/libxml2/libxml/pattern.h +100 -0
  32. data/ext/nokogiri/include/libxml2/libxml/relaxng.h +217 -0
  33. data/ext/nokogiri/include/libxml2/libxml/schemasInternals.h +958 -0
  34. data/ext/nokogiri/include/libxml2/libxml/schematron.h +142 -0
  35. data/ext/nokogiri/include/libxml2/libxml/threads.h +89 -0
  36. data/ext/nokogiri/include/libxml2/libxml/tree.h +1311 -0
  37. data/ext/nokogiri/include/libxml2/libxml/uri.h +94 -0
  38. data/ext/nokogiri/include/libxml2/libxml/valid.h +458 -0
  39. data/ext/nokogiri/include/libxml2/libxml/xinclude.h +129 -0
  40. data/ext/nokogiri/include/libxml2/libxml/xlink.h +189 -0
  41. data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +366 -0
  42. data/ext/nokogiri/include/libxml2/libxml/xmlautomata.h +146 -0
  43. data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +945 -0
  44. data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +153 -0
  45. data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +224 -0
  46. data/ext/nokogiri/include/libxml2/libxml/xmlmodule.h +57 -0
  47. data/ext/nokogiri/include/libxml2/libxml/xmlreader.h +428 -0
  48. data/ext/nokogiri/include/libxml2/libxml/xmlregexp.h +222 -0
  49. data/ext/nokogiri/include/libxml2/libxml/xmlsave.h +88 -0
  50. data/ext/nokogiri/include/libxml2/libxml/xmlschemas.h +246 -0
  51. data/ext/nokogiri/include/libxml2/libxml/xmlschemastypes.h +151 -0
  52. data/ext/nokogiri/include/libxml2/libxml/xmlstring.h +140 -0
  53. data/ext/nokogiri/include/libxml2/libxml/xmlunicode.h +202 -0
  54. data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +485 -0
  55. data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +488 -0
  56. data/ext/nokogiri/include/libxml2/libxml/xpath.h +566 -0
  57. data/ext/nokogiri/include/libxml2/libxml/xpathInternals.h +632 -0
  58. data/ext/nokogiri/include/libxml2/libxml/xpointer.h +114 -0
  59. data/ext/nokogiri/include/libxslt/attributes.h +38 -0
  60. data/ext/nokogiri/include/libxslt/documents.h +93 -0
  61. data/ext/nokogiri/include/libxslt/extensions.h +262 -0
  62. data/ext/nokogiri/include/libxslt/extra.h +72 -0
  63. data/ext/nokogiri/include/libxslt/functions.h +78 -0
  64. data/ext/nokogiri/include/libxslt/imports.h +75 -0
  65. data/ext/nokogiri/include/libxslt/keys.h +53 -0
  66. data/ext/nokogiri/include/libxslt/namespaces.h +68 -0
  67. data/ext/nokogiri/include/libxslt/numbersInternals.h +73 -0
  68. data/ext/nokogiri/include/libxslt/pattern.h +84 -0
  69. data/ext/nokogiri/include/libxslt/preproc.h +43 -0
  70. data/ext/nokogiri/include/libxslt/security.h +104 -0
  71. data/ext/nokogiri/include/libxslt/templates.h +77 -0
  72. data/ext/nokogiri/include/libxslt/transform.h +207 -0
  73. data/ext/nokogiri/include/libxslt/variables.h +118 -0
  74. data/ext/nokogiri/include/libxslt/xslt.h +110 -0
  75. data/ext/nokogiri/include/libxslt/xsltInternals.h +1978 -0
  76. data/ext/nokogiri/include/libxslt/xsltconfig.h +180 -0
  77. data/ext/nokogiri/include/libxslt/xsltexports.h +142 -0
  78. data/ext/nokogiri/include/libxslt/xsltlocale.h +76 -0
  79. data/ext/nokogiri/include/libxslt/xsltutils.h +313 -0
  80. data/ext/nokogiri/nokogiri.c +34 -40
  81. data/ext/nokogiri/nokogiri.h +26 -17
  82. data/ext/nokogiri/xml_document.c +18 -4
  83. data/ext/nokogiri/xml_io.c +8 -6
  84. data/ext/nokogiri/xml_node.c +21 -1
  85. data/ext/nokogiri/xml_node_set.c +1 -1
  86. data/ext/nokogiri/xml_reader.c +6 -17
  87. data/ext/nokogiri/xml_relax_ng.c +29 -11
  88. data/ext/nokogiri/xml_sax_parser.c +2 -7
  89. data/ext/nokogiri/xml_sax_parser_context.c +2 -2
  90. data/ext/nokogiri/xml_schema.c +55 -13
  91. data/ext/nokogiri/xml_xpath_context.c +80 -4
  92. data/ext/nokogiri/xslt_stylesheet.c +1 -8
  93. data/lib/nokogiri.rb +22 -22
  94. data/lib/nokogiri/2.5/nokogiri.so +0 -0
  95. data/lib/nokogiri/2.6/nokogiri.so +0 -0
  96. data/lib/nokogiri/2.7/nokogiri.so +0 -0
  97. data/lib/nokogiri/3.0/nokogiri.so +0 -0
  98. data/lib/nokogiri/css.rb +1 -0
  99. data/lib/nokogiri/css/node.rb +1 -0
  100. data/lib/nokogiri/css/parser.rb +63 -62
  101. data/lib/nokogiri/css/parser.y +2 -2
  102. data/lib/nokogiri/css/parser_extras.rb +39 -36
  103. data/lib/nokogiri/css/syntax_error.rb +1 -0
  104. data/lib/nokogiri/css/tokenizer.rb +1 -0
  105. data/lib/nokogiri/css/xpath_visitor.rb +73 -43
  106. data/lib/nokogiri/decorators/slop.rb +1 -0
  107. data/lib/nokogiri/html.rb +1 -0
  108. data/lib/nokogiri/html/builder.rb +1 -0
  109. data/lib/nokogiri/html/document.rb +13 -26
  110. data/lib/nokogiri/html/document_fragment.rb +1 -0
  111. data/lib/nokogiri/html/element_description.rb +1 -0
  112. data/lib/nokogiri/html/element_description_defaults.rb +1 -0
  113. data/lib/nokogiri/html/entity_lookup.rb +1 -0
  114. data/lib/nokogiri/html/sax/parser.rb +1 -0
  115. data/lib/nokogiri/html/sax/parser_context.rb +1 -0
  116. data/lib/nokogiri/html/sax/push_parser.rb +1 -0
  117. data/lib/nokogiri/jruby/dependencies.rb +20 -0
  118. data/lib/nokogiri/syntax_error.rb +1 -0
  119. data/lib/nokogiri/version.rb +3 -109
  120. data/lib/nokogiri/version/constant.rb +5 -0
  121. data/lib/nokogiri/version/info.rb +182 -0
  122. data/lib/nokogiri/xml.rb +1 -0
  123. data/lib/nokogiri/xml/attr.rb +1 -0
  124. data/lib/nokogiri/xml/attribute_decl.rb +1 -0
  125. data/lib/nokogiri/xml/builder.rb +3 -2
  126. data/lib/nokogiri/xml/cdata.rb +1 -0
  127. data/lib/nokogiri/xml/character_data.rb +1 -0
  128. data/lib/nokogiri/xml/document.rb +20 -15
  129. data/lib/nokogiri/xml/document_fragment.rb +5 -6
  130. data/lib/nokogiri/xml/dtd.rb +1 -0
  131. data/lib/nokogiri/xml/element_content.rb +1 -0
  132. data/lib/nokogiri/xml/element_decl.rb +1 -0
  133. data/lib/nokogiri/xml/entity_decl.rb +1 -0
  134. data/lib/nokogiri/xml/entity_reference.rb +1 -0
  135. data/lib/nokogiri/xml/namespace.rb +1 -0
  136. data/lib/nokogiri/xml/node.rb +587 -249
  137. data/lib/nokogiri/xml/node/save_options.rb +1 -0
  138. data/lib/nokogiri/xml/node_set.rb +1 -0
  139. data/lib/nokogiri/xml/notation.rb +1 -0
  140. data/lib/nokogiri/xml/parse_options.rb +10 -3
  141. data/lib/nokogiri/xml/pp.rb +1 -0
  142. data/lib/nokogiri/xml/pp/character_data.rb +1 -0
  143. data/lib/nokogiri/xml/pp/node.rb +1 -0
  144. data/lib/nokogiri/xml/processing_instruction.rb +1 -0
  145. data/lib/nokogiri/xml/reader.rb +7 -3
  146. data/lib/nokogiri/xml/relax_ng.rb +7 -2
  147. data/lib/nokogiri/xml/sax.rb +1 -0
  148. data/lib/nokogiri/xml/sax/document.rb +1 -0
  149. data/lib/nokogiri/xml/sax/parser.rb +1 -0
  150. data/lib/nokogiri/xml/sax/parser_context.rb +1 -0
  151. data/lib/nokogiri/xml/sax/push_parser.rb +1 -0
  152. data/lib/nokogiri/xml/schema.rb +13 -4
  153. data/lib/nokogiri/xml/searchable.rb +25 -16
  154. data/lib/nokogiri/xml/syntax_error.rb +1 -0
  155. data/lib/nokogiri/xml/text.rb +1 -0
  156. data/lib/nokogiri/xml/xpath.rb +1 -0
  157. data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -0
  158. data/lib/nokogiri/xml/xpath_context.rb +1 -0
  159. data/lib/nokogiri/xslt.rb +1 -0
  160. data/lib/nokogiri/xslt/stylesheet.rb +1 -0
  161. data/lib/xsd/xmlparser/nokogiri.rb +1 -0
  162. metadata +148 -131
  163. data/lib/nokogiri/2.3/nokogiri.so +0 -0
  164. data/lib/nokogiri/2.4/nokogiri.so +0 -0
@@ -1,8 +1,5 @@
1
1
  #include <xml_sax_parser.h>
2
2
 
3
- int vasprintf (char **strp, const char *fmt, va_list ap);
4
- void vasprintf_free (void *p);
5
-
6
3
  static ID id_start_document, id_end_document, id_start_element, id_end_element;
7
4
  static ID id_start_element_namespace, id_end_element_namespace;
8
5
  static ID id_comment, id_characters, id_xmldecl, id_error, id_warning;
@@ -206,7 +203,7 @@ static void warning_func(void * ctx, const char *msg, ...)
206
203
  va_end(args);
207
204
 
208
205
  ruby_message = NOKOGIRI_STR_NEW2(message);
209
- vasprintf_free(message);
206
+ free(message);
210
207
  rb_funcall(doc, id_warning, 1, ruby_message);
211
208
  }
212
209
 
@@ -223,7 +220,7 @@ static void error_func(void * ctx, const char *msg, ...)
223
220
  va_end(args);
224
221
 
225
222
  ruby_message = NOKOGIRI_STR_NEW2(message);
226
- vasprintf_free(message);
223
+ free(message);
227
224
  rb_funcall(doc, id_error, 1, ruby_message);
228
225
  }
229
226
 
@@ -262,8 +259,6 @@ static VALUE allocate(VALUE klass)
262
259
  {
263
260
  xmlSAXHandlerPtr handler = calloc((size_t)1, sizeof(xmlSAXHandler));
264
261
 
265
- xmlSetStructuredErrorFunc(NULL, NULL);
266
-
267
262
  handler->startDocument = start_document;
268
263
  handler->endDocument = end_document;
269
264
  handler->startElement = start_element;
@@ -4,13 +4,13 @@ VALUE cNokogiriXmlSaxParserContext ;
4
4
 
5
5
  static void deallocate(xmlParserCtxtPtr ctxt)
6
6
  {
7
- NOKOGIRI_DEBUG_START(handler);
7
+ NOKOGIRI_DEBUG_START(ctxt);
8
8
 
9
9
  ctxt->sax = NULL;
10
10
 
11
11
  xmlFreeParserCtxt(ctxt);
12
12
 
13
- NOKOGIRI_DEBUG_END(handler);
13
+ NOKOGIRI_DEBUG_END(ctxt);
14
14
  }
15
15
 
16
16
  /*
@@ -93,15 +93,27 @@ static VALUE validate_file(VALUE self, VALUE rb_filename)
93
93
  *
94
94
  * Create a new Schema from the contents of +string+
95
95
  */
96
- static VALUE read_memory(VALUE klass, VALUE content)
96
+ static VALUE read_memory(int argc, VALUE *argv, VALUE klass)
97
97
  {
98
+ VALUE content;
99
+ VALUE parse_options;
100
+ int parse_options_int;
101
+ xmlSchemaParserCtxtPtr ctx;
98
102
  xmlSchemaPtr schema;
99
- xmlSchemaParserCtxtPtr ctx = xmlSchemaNewMemParserCtxt(
100
- (const char *)StringValuePtr(content),
101
- (int)RSTRING_LEN(content)
102
- );
103
+ VALUE errors;
103
104
  VALUE rb_schema;
104
- VALUE errors = rb_ary_new();
105
+ int scanned_args = 0;
106
+ xmlExternalEntityLoader old_loader = 0;
107
+
108
+ scanned_args = rb_scan_args(argc, argv, "11", &content, &parse_options);
109
+ if (scanned_args == 1) {
110
+ parse_options = rb_const_get(rb_const_get(mNokogiriXml, rb_intern("ParseOptions")), rb_intern("DEFAULT_SCHEMA"));
111
+ }
112
+ parse_options_int = (int)NUM2INT(rb_funcall(parse_options, rb_intern("to_i"), 0));
113
+
114
+ ctx = xmlSchemaNewMemParserCtxt((const char *)StringValuePtr(content), (int)RSTRING_LEN(content));
115
+
116
+ errors = rb_ary_new();
105
117
  xmlSetStructuredErrorFunc((void *)errors, Nokogiri_error_array_pusher);
106
118
 
107
119
  #ifdef HAVE_XMLSCHEMASETPARSERSTRUCTUREDERRORS
@@ -109,10 +121,19 @@ static VALUE read_memory(VALUE klass, VALUE content)
109
121
  ctx,
110
122
  Nokogiri_error_array_pusher,
111
123
  (void *)errors
112
- );
124
+ );
113
125
  #endif
114
126
 
115
- schema = xmlSchemaParse(ctx);
127
+ if (parse_options_int & XML_PARSE_NONET) {
128
+ old_loader = xmlGetExternalEntityLoader();
129
+ xmlSetExternalEntityLoader(xmlNoNetExternalEntityLoader);
130
+ }
131
+
132
+ schema = xmlSchemaParse(ctx);
133
+
134
+ if (old_loader) {
135
+ xmlSetExternalEntityLoader(old_loader);
136
+ }
116
137
 
117
138
  xmlSetStructuredErrorFunc(NULL, NULL);
118
139
  xmlSchemaFreeParserCtxt(ctx);
@@ -129,6 +150,7 @@ static VALUE read_memory(VALUE klass, VALUE content)
129
150
 
130
151
  rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema);
131
152
  rb_iv_set(rb_schema, "@errors", errors);
153
+ rb_iv_set(rb_schema, "@parse_options", parse_options);
132
154
 
133
155
  return rb_schema;
134
156
  }
@@ -164,18 +186,28 @@ static int has_blank_nodes_p(VALUE cache)
164
186
  *
165
187
  * Create a new Schema from the Nokogiri::XML::Document +doc+
166
188
  */
167
- static VALUE from_document(VALUE klass, VALUE document)
189
+ static VALUE from_document(int argc, VALUE *argv, VALUE klass)
168
190
  {
191
+ VALUE document;
192
+ VALUE parse_options;
193
+ int parse_options_int;
169
194
  xmlDocPtr doc;
170
195
  xmlSchemaParserCtxtPtr ctx;
171
196
  xmlSchemaPtr schema;
172
197
  VALUE errors;
173
198
  VALUE rb_schema;
199
+ int scanned_args = 0;
200
+ xmlExternalEntityLoader old_loader = 0;
201
+
202
+ scanned_args = rb_scan_args(argc, argv, "11", &document, &parse_options);
174
203
 
175
204
  Data_Get_Struct(document, xmlDoc, doc);
205
+ doc = doc->doc; /* In case someone passes us a node. ugh. */
176
206
 
177
- /* In case someone passes us a node. ugh. */
178
- doc = doc->doc;
207
+ if (scanned_args == 1) {
208
+ parse_options = rb_const_get(rb_const_get(mNokogiriXml, rb_intern("ParseOptions")), rb_intern("DEFAULT_SCHEMA"));
209
+ }
210
+ parse_options_int = (int)NUM2INT(rb_funcall(parse_options, rb_intern("to_i"), 0));
179
211
 
180
212
  if (has_blank_nodes_p(DOC_NODE_CACHE(doc))) {
181
213
  rb_raise(rb_eArgError, "Creating a schema from a document that has blank nodes exposed to Ruby is dangerous");
@@ -194,8 +226,17 @@ static VALUE from_document(VALUE klass, VALUE document)
194
226
  );
195
227
  #endif
196
228
 
229
+ if (parse_options_int & XML_PARSE_NONET) {
230
+ old_loader = xmlGetExternalEntityLoader();
231
+ xmlSetExternalEntityLoader(xmlNoNetExternalEntityLoader);
232
+ }
233
+
197
234
  schema = xmlSchemaParse(ctx);
198
235
 
236
+ if (old_loader) {
237
+ xmlSetExternalEntityLoader(old_loader);
238
+ }
239
+
199
240
  xmlSetStructuredErrorFunc(NULL, NULL);
200
241
  xmlSchemaFreeParserCtxt(ctx);
201
242
 
@@ -211,6 +252,7 @@ static VALUE from_document(VALUE klass, VALUE document)
211
252
 
212
253
  rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema);
213
254
  rb_iv_set(rb_schema, "@errors", errors);
255
+ rb_iv_set(rb_schema, "@parse_options", parse_options);
214
256
 
215
257
  return rb_schema;
216
258
 
@@ -226,8 +268,8 @@ void init_xml_schema()
226
268
 
227
269
  cNokogiriXmlSchema = klass;
228
270
 
229
- rb_define_singleton_method(klass, "read_memory", read_memory, 1);
230
- rb_define_singleton_method(klass, "from_document", from_document, 1);
271
+ rb_define_singleton_method(klass, "read_memory", read_memory, -1);
272
+ rb_define_singleton_method(klass, "from_document", from_document, -1);
231
273
 
232
274
  rb_define_private_method(klass, "validate_document", validate_document, 1);
233
275
  rb_define_private_method(klass, "validate_file", validate_file, 1);
@@ -1,6 +1,11 @@
1
1
  #include <xml_xpath_context.h>
2
2
 
3
- int vasprintf (char **strp, const char *fmt, va_list ap);
3
+ /*
4
+ * these constants have matching declarations in
5
+ * ext/java/nokogiri/internals/NokogiriNamespaceContext.java
6
+ */
7
+ static const xmlChar *NOKOGIRI_BUILTIN_PREFIX = (const xmlChar *)"nokogiri-builtin";
8
+ static const xmlChar *NOKOGIRI_BUILTIN_URI = (const xmlChar *)"https://www.nokogiri.org/default_ns/ruby/builtins";
4
9
 
5
10
  static void deallocate(xmlXPathContextPtr ctx)
6
11
  {
@@ -9,6 +14,73 @@ static void deallocate(xmlXPathContextPtr ctx)
9
14
  NOKOGIRI_DEBUG_END(ctx);
10
15
  }
11
16
 
17
+ /* find a CSS class in an HTML element's `class` attribute */
18
+ const xmlChar* builtin_css_class(const xmlChar* str, const xmlChar *val)
19
+ {
20
+ int val_len;
21
+
22
+ if (str == NULL) { return(NULL); }
23
+ if (val == NULL) { return(NULL); }
24
+
25
+ val_len = xmlStrlen(val);
26
+ if (val_len == 0) { return(str); }
27
+
28
+ while (*str != 0) {
29
+ if ((*str == *val) && !xmlStrncmp(str, val, val_len)) {
30
+ const xmlChar* next_byte = str + val_len;
31
+
32
+ /* only match if the next byte is whitespace or end of string */
33
+ if ((*next_byte == 0) || (IS_BLANK_CH(*next_byte))) {
34
+ return((const xmlChar*)str);
35
+ }
36
+ }
37
+
38
+ /* advance str to whitespace */
39
+ while ((*str != 0) && !IS_BLANK_CH(*str)) {
40
+ str++;
41
+ }
42
+
43
+ /* advance str to start of next word or end of string */
44
+ while ((*str != 0) && IS_BLANK_CH(*str)) {
45
+ str++;
46
+ }
47
+ }
48
+
49
+ return(NULL);
50
+ }
51
+
52
+ /* xmlXPathFunction to wrap builtin_css_class() */
53
+ static void xpath_builtin_css_class(xmlXPathParserContextPtr ctxt, int nargs)
54
+ {
55
+ xmlXPathObjectPtr hay, needle;
56
+
57
+ CHECK_ARITY(2);
58
+
59
+ CAST_TO_STRING;
60
+ needle = valuePop(ctxt);
61
+ if ((needle == NULL) || (needle->type != XPATH_STRING)) {
62
+ xmlXPathFreeObject(needle);
63
+ XP_ERROR(XPATH_INVALID_TYPE);
64
+ }
65
+
66
+ CAST_TO_STRING;
67
+ hay = valuePop(ctxt);
68
+ if ((hay == NULL) || (hay->type != XPATH_STRING)) {
69
+ xmlXPathFreeObject(hay);
70
+ xmlXPathFreeObject(needle);
71
+ XP_ERROR(XPATH_INVALID_TYPE);
72
+ }
73
+
74
+ if (builtin_css_class(hay->stringval, needle->stringval)) {
75
+ valuePush(ctxt, xmlXPathNewBoolean(1));
76
+ } else {
77
+ valuePush(ctxt, xmlXPathNewBoolean(0));
78
+ }
79
+
80
+ xmlXPathFreeObject(hay);
81
+ xmlXPathFreeObject(needle);
82
+ }
83
+
12
84
  /*
13
85
  * call-seq:
14
86
  * register_ns(prefix, uri)
@@ -263,14 +335,18 @@ static VALUE new(VALUE klass, VALUE nodeobj)
263
335
  xmlXPathContextPtr ctx;
264
336
  VALUE self;
265
337
 
266
- xmlXPathInit();
267
-
268
338
  Data_Get_Struct(nodeobj, xmlNode, node);
269
339
 
340
+ xmlXPathInit();
341
+
270
342
  ctx = xmlXPathNewContext(node->doc);
271
343
  ctx->node = node;
344
+
345
+ xmlXPathRegisterNs(ctx, NOKOGIRI_BUILTIN_PREFIX, NOKOGIRI_BUILTIN_URI);
346
+ xmlXPathRegisterFuncNS(ctx, (const xmlChar *)"css-class", NOKOGIRI_BUILTIN_URI,
347
+ xpath_builtin_css_class);
348
+
272
349
  self = Data_Wrap_Struct(klass, 0, deallocate, ctx);
273
- /*rb_iv_set(self, "@xpath_handler", Qnil); */
274
350
  return self;
275
351
  }
276
352
 
@@ -7,9 +7,6 @@
7
7
 
8
8
  VALUE xslt;
9
9
 
10
- int vasprintf (char **strp, const char *fmt, va_list ap);
11
- void vasprintf_free (void *p);
12
-
13
10
  static void mark(nokogiriXsltStylesheetTuple *wrapper)
14
11
  {
15
12
  rb_gc_mark(wrapper->func_instances);
@@ -37,7 +34,7 @@ static void xslt_generic_error_handler(void * ctx, const char *msg, ...)
37
34
 
38
35
  rb_str_cat2((VALUE)ctx, message);
39
36
 
40
- vasprintf_free(message);
37
+ free(message);
41
38
  }
42
39
 
43
40
  VALUE Nokogiri_wrap_xslt_stylesheet(xsltStylesheetPtr ss)
@@ -109,10 +106,6 @@ static VALUE serialize(VALUE self, VALUE xmlobj)
109
106
  return rval ;
110
107
  }
111
108
 
112
- static void swallow_superfluous_xml_errors(void * userdata, xmlErrorPtr error, ...)
113
- {
114
- }
115
-
116
109
  /*
117
110
  * call-seq:
118
111
  * transform(document, params = [])
@@ -1,34 +1,34 @@
1
1
  # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: true
2
3
  # Modify the PATH on windows so that the external DLLs will get loaded.
3
4
 
4
5
  require 'rbconfig'
5
6
 
6
7
  if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
7
- # The line below caused a problem on non-GAE rack environment.
8
- # unless defined?(JRuby::Rack::VERSION) || defined?(AppEngine::ApiProxy)
9
- #
10
- # However, simply cutting defined?(JRuby::Rack::VERSION) off resulted in
11
- # an unable-to-load-nokogiri problem. Thus, now, Nokogiri checks the presense
12
- # of appengine-rack.jar in $LOAD_PATH. If Nokogiri is on GAE, Nokogiri
13
- # should skip loading xml jars. This is because those are in WEB-INF/lib and
14
- # already set in the classpath.
15
- unless $LOAD_PATH.to_s.include?("appengine-rack")
16
- require 'stringio'
17
- require 'isorelax.jar'
18
- require 'jing.jar'
19
- require 'nekohtml.jar'
20
- require 'nekodtd.jar'
21
- require 'xercesImpl.jar'
22
- require 'serializer.jar'
23
- require 'xalan.jar'
24
- require 'xml-apis.jar'
25
- end
8
+ require 'nokogiri/jruby/dependencies'
26
9
  end
27
10
 
28
11
  begin
29
12
  RUBY_VERSION =~ /(\d+\.\d+)/
30
13
  require "nokogiri/#{$1}/nokogiri"
31
- rescue LoadError
14
+ rescue LoadError => e
15
+ if e.message =~ /GLIBC/
16
+ warn <<~EOM
17
+
18
+ ERROR: It looks like you're trying to use Nokogiri as a precompiled native gem on a system with glibc < 2.17:
19
+
20
+ #{e.message}
21
+
22
+ If that's the case, then please install Nokogiri via the `ruby` platform gem:
23
+ gem install nokogiri --platform=ruby
24
+ or:
25
+ bundle config set force_ruby_platform true
26
+
27
+ Please visit https://nokogiri.org/tutorials/installing_nokogiri.html for more help.
28
+
29
+ EOM
30
+ raise e
31
+ end
32
32
  require 'nokogiri/nokogiri'
33
33
  end
34
34
  require 'nokogiri/version'
@@ -54,7 +54,7 @@ require 'nokogiri/html/builder'
54
54
  #
55
55
  # # Get a Nokogiri::HTML:Document for the page we’re interested in...
56
56
  #
57
- # doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
57
+ # doc = Nokogiri::HTML(URI.open('http://www.google.com/search?q=tenderlove'))
58
58
  #
59
59
  # # Do funky things with it using Nokogiri::XML::Node methods...
60
60
  #
@@ -130,7 +130,7 @@ module Nokogiri
130
130
  end
131
131
 
132
132
  ###
133
- # Parser a document contained in +args+. Nokogiri will try to guess what
133
+ # Parse a document contained in +args+. Nokogiri will try to guess what
134
134
  # type of document you are attempting to parse. For more information, see
135
135
  # Nokogiri.parse
136
136
  #
Binary file
Binary file
Binary file
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'nokogiri/css/node'
2
3
  require 'nokogiri/css/xpath_visitor'
3
4
  x = $-w
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Nokogiri
2
3
  module CSS
3
4
  class Node
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.4.14
4
- # from Racc grammer file "".
4
+ # This file is automatically generated by Racc 1.5.1
5
+ # from Racc grammar file "".
5
6
  #
6
7
 
7
8
  require 'racc/parser.rb'
@@ -333,42 +334,42 @@ Racc_debug_parser = false
333
334
 
334
335
  def _reduce_1(val, _values, result)
335
336
  result = [val.first, val.last].flatten
336
-
337
+
337
338
  result
338
339
  end
339
340
 
340
341
  def _reduce_2(val, _values, result)
341
- result = val.flatten
342
+ result = val.flatten
342
343
  result
343
344
  end
344
345
 
345
346
  def _reduce_3(val, _values, result)
346
- result = [val.last].flatten
347
+ result = [val.last].flatten
347
348
  result
348
349
  end
349
350
 
350
351
  def _reduce_4(val, _values, result)
351
- result = :DIRECT_ADJACENT_SELECTOR
352
+ result = :DIRECT_ADJACENT_SELECTOR
352
353
  result
353
354
  end
354
355
 
355
356
  def _reduce_5(val, _values, result)
356
- result = :CHILD_SELECTOR
357
+ result = :CHILD_SELECTOR
357
358
  result
358
359
  end
359
360
 
360
361
  def _reduce_6(val, _values, result)
361
- result = :FOLLOWING_SELECTOR
362
+ result = :FOLLOWING_SELECTOR
362
363
  result
363
364
  end
364
365
 
365
366
  def _reduce_7(val, _values, result)
366
- result = :DESCENDANT_SELECTOR
367
+ result = :DESCENDANT_SELECTOR
367
368
  result
368
369
  end
369
370
 
370
371
  def _reduce_8(val, _values, result)
371
- result = :CHILD_SELECTOR
372
+ result = :CHILD_SELECTOR
372
373
  result
373
374
  end
374
375
 
@@ -378,7 +379,7 @@ def _reduce_9(val, _values, result)
378
379
  else
379
380
  Node.new(:CONDITIONAL_SELECTOR, [val.first, val[1]])
380
381
  end
381
-
382
+
382
383
  result
383
384
  end
384
385
 
@@ -386,13 +387,13 @@ end
386
387
 
387
388
  def _reduce_11(val, _values, result)
388
389
  result = Node.new(:CONDITIONAL_SELECTOR, val)
389
-
390
+
390
391
  result
391
392
  end
392
393
 
393
394
  def _reduce_12(val, _values, result)
394
395
  result = Node.new(:CONDITIONAL_SELECTOR, val)
395
-
396
+
396
397
  result
397
398
  end
398
399
 
@@ -400,39 +401,39 @@ def _reduce_13(val, _values, result)
400
401
  result = Node.new(:CONDITIONAL_SELECTOR,
401
402
  [Node.new(:ELEMENT_NAME, ['*']), val.first]
402
403
  )
403
-
404
+
404
405
  result
405
406
  end
406
407
 
407
408
  def _reduce_14(val, _values, result)
408
409
  result = Node.new(val.first, [nil, val.last])
409
-
410
+
410
411
  result
411
412
  end
412
413
 
413
414
  def _reduce_15(val, _values, result)
414
415
  result = Node.new(val[1], [val.first, val.last])
415
-
416
+
416
417
  result
417
418
  end
418
419
 
419
420
  def _reduce_16(val, _values, result)
420
421
  result = Node.new(:DESCENDANT_SELECTOR, [val.first, val.last])
421
-
422
+
422
423
  result
423
424
  end
424
425
 
425
426
  # reduce 17 omitted
426
427
 
427
428
  def _reduce_18(val, _values, result)
428
- result = Node.new(:CLASS_CONDITION, [unescape_css_identifier(val[1])])
429
+ result = Node.new(:CLASS_CONDITION, [unescape_css_identifier(val[1])])
429
430
  result
430
431
  end
431
432
 
432
433
  # reduce 19 omitted
433
434
 
434
435
  def _reduce_20(val, _values, result)
435
- result = Node.new(:ELEMENT_NAME, val)
436
+ result = Node.new(:ELEMENT_NAME, val)
436
437
  result
437
438
  end
438
439
 
@@ -440,19 +441,19 @@ def _reduce_21(val, _values, result)
440
441
  result = Node.new(:ELEMENT_NAME,
441
442
  [[val.first, val.last].compact.join(':')]
442
443
  )
443
-
444
+
444
445
  result
445
446
  end
446
447
 
447
448
  def _reduce_22(val, _values, result)
448
449
  name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first
449
450
  result = Node.new(:ELEMENT_NAME, [name])
450
-
451
+
451
452
  result
452
453
  end
453
454
 
454
455
  def _reduce_23(val, _values, result)
455
- result = val[0]
456
+ result = val[0]
456
457
  result
457
458
  end
458
459
 
@@ -462,7 +463,7 @@ def _reduce_25(val, _values, result)
462
463
  result = Node.new(:ATTRIBUTE_CONDITION,
463
464
  [val[1]] + (val[2] || [])
464
465
  )
465
-
466
+
466
467
  result
467
468
  end
468
469
 
@@ -470,16 +471,16 @@ def _reduce_26(val, _values, result)
470
471
  result = Node.new(:ATTRIBUTE_CONDITION,
471
472
  [val[1]] + (val[2] || [])
472
473
  )
473
-
474
+
474
475
  result
475
476
  end
476
477
 
477
478
  def _reduce_27(val, _values, result)
478
- # Non standard, but hpricot supports it.
479
+ # non-standard, from hpricot
479
480
  result = Node.new(:PSEUDO_CLASS,
480
481
  [Node.new(:FUNCTION, ['nth-child(', val[1]])]
481
482
  )
482
-
483
+
483
484
  result
484
485
  end
485
486
 
@@ -487,7 +488,7 @@ def _reduce_28(val, _values, result)
487
488
  result = Node.new(:ELEMENT_NAME,
488
489
  [[val.first, val.last].compact.join(':')]
489
490
  )
490
-
491
+
491
492
  result
492
493
  end
493
494
 
@@ -495,52 +496,52 @@ def _reduce_29(val, _values, result)
495
496
  # Default namespace is not applied to attributes.
496
497
  # So we don't add prefix "xmlns:" as in namespaced_ident.
497
498
  result = Node.new(:ELEMENT_NAME, [val.first])
498
-
499
+
499
500
  result
500
501
  end
501
502
 
502
503
  def _reduce_30(val, _values, result)
503
504
  result = Node.new(:FUNCTION, [val.first.strip])
504
-
505
+
505
506
  result
506
507
  end
507
508
 
508
509
  def _reduce_31(val, _values, result)
509
510
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
510
-
511
+
511
512
  result
512
513
  end
513
514
 
514
515
  def _reduce_32(val, _values, result)
515
516
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
516
-
517
+
517
518
  result
518
519
  end
519
520
 
520
521
  def _reduce_33(val, _values, result)
521
522
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
522
-
523
+
523
524
  result
524
525
  end
525
526
 
526
527
  def _reduce_34(val, _values, result)
527
528
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
528
-
529
+
529
530
  result
530
531
  end
531
532
 
532
533
  def _reduce_35(val, _values, result)
533
- result = [val.first, val.last]
534
+ result = [val.first, val.last]
534
535
  result
535
536
  end
536
537
 
537
538
  def _reduce_36(val, _values, result)
538
- result = [val.first, val.last]
539
+ result = [val.first, val.last]
539
540
  result
540
541
  end
541
542
 
542
543
  def _reduce_37(val, _values, result)
543
- result = [val.first, val.last]
544
+ result = [val.first, val.last]
544
545
  result
545
546
  end
546
547
 
@@ -557,13 +558,13 @@ def _reduce_40(val, _values, result)
557
558
  when 'n'
558
559
  result = Node.new(:NTH, ['1','n','+','0'])
559
560
  else
560
- # This is not CSS standard. It allows us to support this:
561
+ # non-standard to support custom functions:
561
562
  # assert_xpath("//a[foo(., @href)]", @parser.parse('a:foo(@href)'))
562
563
  # assert_xpath("//a[foo(., @a, b)]", @parser.parse('a:foo(@a, b)'))
563
564
  # assert_xpath("//a[foo(., a, 10)]", @parser.parse('a:foo(a, 10)'))
564
565
  result = val
565
566
  end
566
-
567
+
567
568
  result
568
569
  end
569
570
 
@@ -573,7 +574,7 @@ def _reduce_41(val, _values, result)
573
574
  else
574
575
  raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
575
576
  end
576
-
577
+
577
578
  result
578
579
  end
579
580
 
@@ -589,7 +590,7 @@ def _reduce_42(val, _values, result)
589
590
  else
590
591
  raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
591
592
  end
592
-
593
+
593
594
  result
594
595
  end
595
596
 
@@ -609,18 +610,18 @@ def _reduce_43(val, _values, result)
609
610
  else
610
611
  raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
611
612
  end
612
-
613
+
613
614
  result
614
615
  end
615
616
 
616
617
  def _reduce_44(val, _values, result)
617
618
  result = Node.new(:PSEUDO_CLASS, [val[1]])
618
-
619
+
619
620
  result
620
621
  end
621
622
 
622
623
  def _reduce_45(val, _values, result)
623
- result = Node.new(:PSEUDO_CLASS, [val[1]])
624
+ result = Node.new(:PSEUDO_CLASS, [val[1]])
624
625
  result
625
626
  end
626
627
 
@@ -630,31 +631,31 @@ end
630
631
 
631
632
  def _reduce_48(val, _values, result)
632
633
  result = Node.new(:COMBINATOR, val)
633
-
634
+
634
635
  result
635
636
  end
636
637
 
637
638
  def _reduce_49(val, _values, result)
638
639
  result = Node.new(:COMBINATOR, val)
639
-
640
+
640
641
  result
641
642
  end
642
643
 
643
644
  def _reduce_50(val, _values, result)
644
645
  result = Node.new(:COMBINATOR, val)
645
-
646
+
646
647
  result
647
648
  end
648
649
 
649
650
  def _reduce_51(val, _values, result)
650
651
  result = Node.new(:COMBINATOR, val)
651
-
652
+
652
653
  result
653
654
  end
654
655
 
655
656
  def _reduce_52(val, _values, result)
656
657
  result = Node.new(:COMBINATOR, val)
657
-
658
+
658
659
  result
659
660
  end
660
661
 
@@ -669,65 +670,65 @@ end
669
670
  # reduce 57 omitted
670
671
 
671
672
  def _reduce_58(val, _values, result)
672
- result = Node.new(:ID, [unescape_css_identifier(val.first)])
673
+ result = Node.new(:ID, [unescape_css_identifier(val.first)])
673
674
  result
674
675
  end
675
676
 
676
677
  def _reduce_59(val, _values, result)
677
- result = [val.first, unescape_css_identifier(val[1])]
678
+ result = [val.first, unescape_css_identifier(val[1])]
678
679
  result
679
680
  end
680
681
 
681
682
  def _reduce_60(val, _values, result)
682
- result = [val.first, unescape_css_string(val[1])]
683
+ result = [val.first, unescape_css_string(val[1])]
683
684
  result
684
685
  end
685
686
 
686
687
  def _reduce_61(val, _values, result)
687
- result = [val.first, val[1]]
688
+ result = [val.first, val[1]]
688
689
  result
689
690
  end
690
691
 
691
692
  # reduce 62 omitted
692
693
 
693
694
  def _reduce_63(val, _values, result)
694
- result = :equal
695
+ result = :equal
695
696
  result
696
697
  end
697
698
 
698
699
  def _reduce_64(val, _values, result)
699
- result = :prefix_match
700
+ result = :prefix_match
700
701
  result
701
702
  end
702
703
 
703
704
  def _reduce_65(val, _values, result)
704
- result = :suffix_match
705
+ result = :suffix_match
705
706
  result
706
707
  end
707
708
 
708
709
  def _reduce_66(val, _values, result)
709
- result = :substring_match
710
+ result = :substring_match
710
711
  result
711
712
  end
712
713
 
713
714
  def _reduce_67(val, _values, result)
714
- result = :not_equal
715
+ result = :not_equal
715
716
  result
716
717
  end
717
718
 
718
719
  def _reduce_68(val, _values, result)
719
- result = :includes
720
+ result = :includes
720
721
  result
721
722
  end
722
723
 
723
724
  def _reduce_69(val, _values, result)
724
- result = :dash_match
725
+ result = :dash_match
725
726
  result
726
727
  end
727
728
 
728
729
  def _reduce_70(val, _values, result)
729
730
  result = Node.new(:NOT, [val[1]])
730
-
731
+
731
732
  result
732
733
  end
733
734
 
@@ -746,5 +747,5 @@ def _reduce_none(val, _values, result)
746
747
  end
747
748
 
748
749
  end # class Parser
749
- end # module CSS
750
- end # module Nokogiri
750
+ end # module CSS
751
+ end # module Nokogiri