nokogiri 1.19.2-arm-linux-gnu → 1.19.4-arm-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/nokogiri/nokogiri.c +6 -3
- data/ext/nokogiri/nokogiri.h +11 -2
- data/ext/nokogiri/xml_attr.c +28 -23
- data/ext/nokogiri/xml_document.c +22 -14
- data/ext/nokogiri/xml_node.c +78 -14
- data/ext/nokogiri/xml_node_set.c +1 -1
- data/ext/nokogiri/xml_xpath_context.c +11 -1
- data/ext/nokogiri/xslt_stylesheet.c +41 -5
- data/lib/nokogiri/3.2/nokogiri.so +0 -0
- data/lib/nokogiri/3.3/nokogiri.so +0 -0
- data/lib/nokogiri/3.4/nokogiri.so +0 -0
- data/lib/nokogiri/4.0/nokogiri.so +0 -0
- data/lib/nokogiri/css/tokenizer.rb +5 -5
- data/lib/nokogiri/css/tokenizer.rex +4 -4
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/version/info.rb +10 -0
- data/lib/nokogiri/xml/document.rb +3 -2
- data/lib/nokogiri/xml/node.rb +57 -6
- data/lib/nokogiri/xml/parse_options.rb +11 -7
- data/lib/nokogiri/xml/sax/document.rb +1 -1
- data/lib/nokogiri/xslt/stylesheet.rb +8 -3
- data/lib/nokogiri/xslt.rb +11 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b99ecebac75a3808897b18de47f54fe3bf4f4078b0def8a09444399a77a03ebf
|
|
4
|
+
data.tar.gz: ed838877ae2638fc224a52c6fad2d3abe2a7ceaa860d991d67e94ac6f0de6a87
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '09f5a5bade523251c07f470c687ddbd41e53fee71e4969a1ba9876bc9899a6cd00640ad5fdacdfdc3fd51a9ec373a2eaf090059d8910a8a1b4f594e27775c76b'
|
|
7
|
+
data.tar.gz: 14b65b66eeea77cec362bab4def5cdc5c44f28203b773e12d11c55b8552477924d7083c131dd3b8fd6fa09042d87452df1b8db9fe8a6942c4dd84e573b16f265
|
data/ext/nokogiri/nokogiri.c
CHANGED
|
@@ -203,9 +203,6 @@ Init_nokogiri(void)
|
|
|
203
203
|
rb_const_set(mNokogiri, rb_intern("LIBXSLT_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXSLT_DOTTED_VERSION));
|
|
204
204
|
rb_const_set(mNokogiri, rb_intern("LIBXSLT_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xsltEngineVersion));
|
|
205
205
|
|
|
206
|
-
rb_const_set(mNokogiri, rb_intern("LIBXML_ZLIB_ENABLED"),
|
|
207
|
-
xmlHasFeature(XML_WITH_ZLIB) == 1 ? Qtrue : Qfalse);
|
|
208
|
-
|
|
209
206
|
#ifdef NOKOGIRI_PACKAGED_LIBRARIES
|
|
210
207
|
rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qtrue);
|
|
211
208
|
# ifdef NOKOGIRI_PRECOMPILED_LIBRARIES
|
|
@@ -228,6 +225,12 @@ Init_nokogiri(void)
|
|
|
228
225
|
rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qfalse);
|
|
229
226
|
#endif
|
|
230
227
|
|
|
228
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_ZLIB_ENABLED"),
|
|
229
|
+
xmlHasFeature(XML_WITH_ZLIB) == 1 ? Qtrue : Qfalse);
|
|
230
|
+
|
|
231
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_HTTP_ENABLED"),
|
|
232
|
+
xmlHasFeature(XML_WITH_HTTP) == 1 ? Qtrue : Qfalse);
|
|
233
|
+
|
|
231
234
|
#ifdef NOKOGIRI_OTHER_LIBRARY_VERSIONS
|
|
232
235
|
rb_const_set(mNokogiri, rb_intern("OTHER_LIBRARY_VERSIONS"), NOKOGIRI_STR_NEW2(NOKOGIRI_OTHER_LIBRARY_VERSIONS));
|
|
233
236
|
#endif
|
data/ext/nokogiri/nokogiri.h
CHANGED
|
@@ -181,8 +181,17 @@ int noko_io_read(void *ctx, char *buffer, int len);
|
|
|
181
181
|
int noko_io_write(void *ctx, char *buffer, int len);
|
|
182
182
|
int noko_io_close(void *ctx);
|
|
183
183
|
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
static inline void *
|
|
185
|
+
_noko_data_ptr(VALUE rb_object)
|
|
186
|
+
{
|
|
187
|
+
void *c_data = DATA_PTR(rb_object);
|
|
188
|
+
if (c_data == NULL) {
|
|
189
|
+
rb_raise(rb_eRuntimeError, "Uninitialized %" PRIsVALUE " struct (null data pointer)", rb_obj_class(rb_object));
|
|
190
|
+
}
|
|
191
|
+
return c_data;
|
|
192
|
+
}
|
|
193
|
+
#define Noko_Node_Get_Struct(obj,type,sval) ((sval) = (type*)_noko_data_ptr(obj))
|
|
194
|
+
#define Noko_Namespace_Get_Struct(obj,type,sval) ((sval) = (type*)_noko_data_ptr(obj))
|
|
186
195
|
|
|
187
196
|
VALUE noko_xml_node_wrap(VALUE klass, xmlNodePtr node) ;
|
|
188
197
|
VALUE noko_xml_node_wrap_node_set_result(xmlNodePtr node, VALUE node_set) ;
|
data/ext/nokogiri/xml_attr.c
CHANGED
|
@@ -10,37 +10,42 @@ VALUE cNokogiriXmlAttr;
|
|
|
10
10
|
* (e.g., a HTML boolean attribute).
|
|
11
11
|
*/
|
|
12
12
|
static VALUE
|
|
13
|
-
|
|
13
|
+
noko_xml_attr_set_value(VALUE self, VALUE content)
|
|
14
14
|
{
|
|
15
15
|
xmlAttrPtr attr;
|
|
16
|
-
xmlChar *value;
|
|
17
|
-
xmlNode *cur;
|
|
18
16
|
|
|
19
17
|
Noko_Node_Get_Struct(self, xmlAttr, attr);
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
{
|
|
20
|
+
/* Unlink and pin any wrapped children */
|
|
21
|
+
xmlNode *cur = attr->children;
|
|
22
|
+
xmlNode *next;
|
|
23
|
+
|
|
24
|
+
while (cur) {
|
|
25
|
+
next = cur->next;
|
|
26
|
+
if (cur->_private) {
|
|
27
|
+
xmlUnlinkNode(cur);
|
|
28
|
+
noko_xml_document_pin_node(cur);
|
|
29
|
+
}
|
|
30
|
+
cur = next;
|
|
31
|
+
}
|
|
23
32
|
}
|
|
24
|
-
attr->children = attr->last = NULL;
|
|
25
33
|
|
|
26
34
|
if (content == Qnil) {
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
value = xmlEncodeEntitiesReentrant(attr->doc, (unsigned char *)StringValueCStr(content));
|
|
31
|
-
if (xmlStrlen(value) == 0) {
|
|
32
|
-
attr->children = xmlNewDocText(attr->doc, value);
|
|
35
|
+
xmlNodeSetContent((xmlNodePtr)attr, NULL); /* Clear any remaining unwrapped children. */
|
|
33
36
|
} else {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
xmlChar *value = xmlEncodeEntitiesReentrant(attr->doc, (unsigned char *)StringValueCStr(content));
|
|
38
|
+
|
|
39
|
+
if (xmlStrlen(value) == 0) {
|
|
40
|
+
xmlNodeSetContent((xmlNodePtr)attr, NULL); /* Clear any remaining unwrapped children. */
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
attr
|
|
42
|
+
/* Preserve empty-string attributes as `foo=""` and not boolean `foo` */
|
|
43
|
+
attr->children = attr->last = xmlNewDocText(attr->doc, value);
|
|
44
|
+
attr->children->parent = (xmlNode *)attr;
|
|
45
|
+
} else {
|
|
46
|
+
xmlNodeSetContent((xmlNodePtr)attr, value);
|
|
43
47
|
}
|
|
48
|
+
xmlFree(value);
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
return content;
|
|
@@ -53,7 +58,7 @@ set_value(VALUE self, VALUE content)
|
|
|
53
58
|
* Create a new Attr element on the +document+ with +name+
|
|
54
59
|
*/
|
|
55
60
|
static VALUE
|
|
56
|
-
|
|
61
|
+
noko_xml_attr__new(int argc, VALUE *argv, VALUE klass)
|
|
57
62
|
{
|
|
58
63
|
xmlDocPtr xml_doc;
|
|
59
64
|
VALUE document;
|
|
@@ -97,7 +102,7 @@ noko_init_xml_attr(void)
|
|
|
97
102
|
*/
|
|
98
103
|
cNokogiriXmlAttr = rb_define_class_under(mNokogiriXml, "Attr", cNokogiriXmlNode);
|
|
99
104
|
|
|
100
|
-
rb_define_singleton_method(cNokogiriXmlAttr, "new",
|
|
105
|
+
rb_define_singleton_method(cNokogiriXmlAttr, "new", noko_xml_attr__new, -1);
|
|
101
106
|
|
|
102
|
-
rb_define_method(cNokogiriXmlAttr, "value=",
|
|
107
|
+
rb_define_method(cNokogiriXmlAttr, "value=", noko_xml_attr_set_value, 1);
|
|
103
108
|
}
|
data/ext/nokogiri/xml_document.c
CHANGED
|
@@ -255,12 +255,6 @@ rb_xml_document_root_set(VALUE self, VALUE rb_new_root)
|
|
|
255
255
|
|
|
256
256
|
c_document = noko_xml_document_unwrap(self);
|
|
257
257
|
|
|
258
|
-
c_current_root = xmlDocGetRootElement(c_document);
|
|
259
|
-
if (c_current_root) {
|
|
260
|
-
xmlUnlinkNode(c_current_root);
|
|
261
|
-
noko_xml_document_pin_node(c_current_root);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
258
|
if (!NIL_P(rb_new_root)) {
|
|
265
259
|
if (!rb_obj_is_kind_of(rb_new_root, cNokogiriXmlNode)) {
|
|
266
260
|
rb_raise(rb_eArgError,
|
|
@@ -270,13 +264,23 @@ rb_xml_document_root_set(VALUE self, VALUE rb_new_root)
|
|
|
270
264
|
|
|
271
265
|
Noko_Node_Get_Struct(rb_new_root, xmlNode, c_new_root);
|
|
272
266
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
267
|
+
if (c_new_root->type != XML_ELEMENT_NODE) {
|
|
268
|
+
rb_raise(rb_eTypeError, "root must be a Nokogiri::XML::Element");
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
c_current_root = xmlDocGetRootElement(c_document);
|
|
273
|
+
if (c_current_root) {
|
|
274
|
+
xmlUnlinkNode(c_current_root);
|
|
275
|
+
noko_xml_document_pin_node(c_current_root);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* If the new root's document is not the same as the current document,
|
|
279
|
+
* then we need to dup the node in to this document. */
|
|
280
|
+
if (c_new_root && c_new_root->doc != c_document) {
|
|
281
|
+
c_new_root = xmlDocCopyNode(c_new_root, c_document, 1);
|
|
282
|
+
if (!c_new_root) {
|
|
283
|
+
rb_raise(rb_eRuntimeError, "Could not reparent node (xmlDocCopyNode)");
|
|
280
284
|
}
|
|
281
285
|
}
|
|
282
286
|
|
|
@@ -317,12 +321,13 @@ static VALUE
|
|
|
317
321
|
set_encoding(VALUE self, VALUE encoding)
|
|
318
322
|
{
|
|
319
323
|
xmlDocPtr doc = noko_xml_document_unwrap(self);
|
|
324
|
+
xmlChar *new_encoding = xmlStrdup((xmlChar *)StringValueCStr(encoding));
|
|
320
325
|
|
|
321
326
|
if (doc->encoding) {
|
|
322
327
|
xmlFree(DISCARD_CONST_QUAL_XMLCHAR(doc->encoding));
|
|
323
328
|
}
|
|
324
329
|
|
|
325
|
-
doc->encoding =
|
|
330
|
+
doc->encoding = new_encoding;
|
|
326
331
|
|
|
327
332
|
return encoding;
|
|
328
333
|
}
|
|
@@ -708,6 +713,9 @@ noko_xml_document_unwrap(VALUE rb_document)
|
|
|
708
713
|
{
|
|
709
714
|
xmlDocPtr c_document;
|
|
710
715
|
TypedData_Get_Struct(rb_document, xmlDoc, &xml_doc_type, c_document);
|
|
716
|
+
if (c_document == NULL) {
|
|
717
|
+
rb_raise(rb_eRuntimeError, "Uninitialized %" PRIsVALUE " struct (null data pointer)", rb_obj_class(rb_document));
|
|
718
|
+
}
|
|
711
719
|
return c_document;
|
|
712
720
|
}
|
|
713
721
|
|
data/ext/nokogiri/xml_node.c
CHANGED
|
@@ -971,6 +971,10 @@ rb_xml_node_initialize_copy_with_args(VALUE rb_self, VALUE rb_other, VALUE rb_le
|
|
|
971
971
|
xmlDocPtr c_new_parent_doc;
|
|
972
972
|
VALUE rb_node_cache;
|
|
973
973
|
|
|
974
|
+
if (!rb_obj_is_kind_of(rb_other, cNokogiriXmlNode)) {
|
|
975
|
+
rb_raise(rb_eTypeError, "argument must be a kind of Nokogiri::XML::Node");
|
|
976
|
+
}
|
|
977
|
+
|
|
974
978
|
Noko_Node_Get_Struct(rb_other, xmlNode, c_other);
|
|
975
979
|
c_level = (int)NUM2INT(rb_level);
|
|
976
980
|
c_new_parent_doc = noko_xml_document_unwrap(rb_new_parent_doc);
|
|
@@ -2150,25 +2154,20 @@ compare(VALUE self, VALUE _other)
|
|
|
2150
2154
|
|
|
2151
2155
|
|
|
2152
2156
|
/*
|
|
2153
|
-
*
|
|
2154
|
-
*
|
|
2155
|
-
*
|
|
2156
|
-
* Loads and substitutes all xinclude elements below the node. The
|
|
2157
|
-
* parser context will be initialized with +flags+.
|
|
2157
|
+
* Run XInclude substitution over the tree rooted at +c_node+, with the parser context initialized
|
|
2158
|
+
* from +c_flags+. Collects libxml2's structured errors and raises Nokogiri::XML::SyntaxError (or
|
|
2159
|
+
* RuntimeError) on failure.
|
|
2158
2160
|
*/
|
|
2159
|
-
static
|
|
2160
|
-
|
|
2161
|
+
static void
|
|
2162
|
+
_noko_xml_node_process_xinclude_subtree(xmlNodePtr c_node, int c_flags)
|
|
2161
2163
|
{
|
|
2162
2164
|
int status ;
|
|
2163
|
-
xmlNodePtr c_node;
|
|
2164
2165
|
VALUE rb_errors = rb_ary_new();
|
|
2165
2166
|
libxmlStructuredErrorHandlerState handler_state;
|
|
2166
2167
|
|
|
2167
|
-
Noko_Node_Get_Struct(rb_node, xmlNode, c_node);
|
|
2168
|
-
|
|
2169
2168
|
noko__structured_error_func_save_and_set(&handler_state, (void *)rb_errors, noko__error_array_pusher);
|
|
2170
2169
|
|
|
2171
|
-
status = xmlXIncludeProcessTreeFlags(c_node,
|
|
2170
|
+
status = xmlXIncludeProcessTreeFlags(c_node, c_flags);
|
|
2172
2171
|
|
|
2173
2172
|
noko__structured_error_func_restore(&handler_state);
|
|
2174
2173
|
|
|
@@ -2181,11 +2180,77 @@ noko_xml_node__process_xincludes(VALUE rb_node, VALUE rb_flags)
|
|
|
2181
2180
|
rb_raise(rb_eRuntimeError, "Could not perform xinclude substitution");
|
|
2182
2181
|
}
|
|
2183
2182
|
}
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
|
|
2186
|
+
/*
|
|
2187
|
+
* Whether +c_node+ is an <xi:include> element in either the 2001 or 2003 XInclude namespace.
|
|
2188
|
+
*/
|
|
2189
|
+
static int
|
|
2190
|
+
_noko_xml_node_xinclude_element_p(xmlNodePtr c_node)
|
|
2191
|
+
{
|
|
2192
|
+
return c_node->type == XML_ELEMENT_NODE
|
|
2193
|
+
&& xmlStrEqual(c_node->name, XINCLUDE_NODE)
|
|
2194
|
+
&& c_node->ns != NULL
|
|
2195
|
+
&& (xmlStrEqual(c_node->ns->href, XINCLUDE_NS) || xmlStrEqual(c_node->ns->href, XINCLUDE_OLD_NS));
|
|
2196
|
+
}
|
|
2197
|
+
|
|
2198
|
+
|
|
2199
|
+
/*
|
|
2200
|
+
* call-seq:
|
|
2201
|
+
* process_xincludes(flags)
|
|
2202
|
+
*
|
|
2203
|
+
* Loads and substitutes all xinclude elements below the node. The
|
|
2204
|
+
* parser context will be initialized with +flags+.
|
|
2205
|
+
*/
|
|
2206
|
+
static VALUE
|
|
2207
|
+
noko_xml_node__process_xincludes(VALUE rb_node, VALUE rb_flags)
|
|
2208
|
+
{
|
|
2209
|
+
xmlNodePtr c_node;
|
|
2210
|
+
|
|
2211
|
+
Noko_Node_Get_Struct(rb_node, xmlNode, c_node);
|
|
2212
|
+
|
|
2213
|
+
if (c_node->parent == NULL && _noko_xml_node_xinclude_element_p(c_node)) {
|
|
2214
|
+
rb_raise(rb_eRuntimeError, "cannot process XInclude on an unlinked <xi:include> node");
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
_noko_xml_node_process_xinclude_subtree(c_node, (int)NUM2INT(rb_flags));
|
|
2184
2218
|
|
|
2185
2219
|
return rb_node;
|
|
2186
2220
|
}
|
|
2187
2221
|
|
|
2188
2222
|
|
|
2223
|
+
/*
|
|
2224
|
+
* Process this single <xi:include> node, substituting an unwrapped copy of it in its place so
|
|
2225
|
+
* that libxml2 frees the copy. This node is unlinked and pinned to the document, so any Ruby
|
|
2226
|
+
* wrapper for it (or for its descendants or namespaces) keeps pointing at valid memory. The
|
|
2227
|
+
* parser context is initialized with +flags+.
|
|
2228
|
+
*/
|
|
2229
|
+
static VALUE
|
|
2230
|
+
noko_xml_node__safe_process_xinclude(VALUE rb_node, VALUE rb_flags)
|
|
2231
|
+
{
|
|
2232
|
+
xmlNodePtr c_node, c_copy;
|
|
2233
|
+
|
|
2234
|
+
Noko_Node_Get_Struct(rb_node, xmlNode, c_node);
|
|
2235
|
+
|
|
2236
|
+
if (c_node->parent == NULL) {
|
|
2237
|
+
rb_raise(rb_eRuntimeError, "cannot process XInclude on an unlinked <xi:include> node");
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
c_copy = xmlDocCopyNode(c_node, c_node->doc, 1);
|
|
2241
|
+
if (c_copy == NULL) {
|
|
2242
|
+
rb_raise(rb_eRuntimeError, "Could not copy node for xinclude substitution");
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
xmlReplaceNode(c_node, c_copy);
|
|
2246
|
+
noko_xml_document_pin_node(c_node);
|
|
2247
|
+
|
|
2248
|
+
_noko_xml_node_process_xinclude_subtree(c_copy, (int)NUM2INT(rb_flags));
|
|
2249
|
+
|
|
2250
|
+
return Qnil;
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
|
|
2189
2254
|
/* TODO: DOCUMENT ME */
|
|
2190
2255
|
static VALUE
|
|
2191
2256
|
in_context(VALUE self, VALUE _str, VALUE _options)
|
|
@@ -2286,9 +2351,7 @@ in_context(VALUE self, VALUE _str, VALUE _options)
|
|
|
2286
2351
|
VALUE
|
|
2287
2352
|
rb_xml_node_data_ptr_eh(VALUE self)
|
|
2288
2353
|
{
|
|
2289
|
-
|
|
2290
|
-
Noko_Node_Get_Struct(self, xmlNode, c_node);
|
|
2291
|
-
return c_node ? Qtrue : Qfalse;
|
|
2354
|
+
return DATA_PTR(self) ? Qtrue : Qfalse;
|
|
2292
2355
|
}
|
|
2293
2356
|
|
|
2294
2357
|
VALUE
|
|
@@ -2438,6 +2501,7 @@ noko_init_xml_node(void)
|
|
|
2438
2501
|
rb_define_method(cNokogiriXmlNode, "unlink", unlink_node, 0);
|
|
2439
2502
|
|
|
2440
2503
|
rb_define_protected_method(cNokogiriXmlNode, "initialize_copy_with_args", rb_xml_node_initialize_copy_with_args, 3);
|
|
2504
|
+
rb_define_protected_method(cNokogiriXmlNode, "safe_process_xinclude", noko_xml_node__safe_process_xinclude, 1);
|
|
2441
2505
|
|
|
2442
2506
|
rb_define_private_method(cNokogiriXmlNode, "add_child_node", add_child, 1);
|
|
2443
2507
|
rb_define_private_method(cNokogiriXmlNode, "add_next_sibling_node", add_next_sibling, 1);
|
data/ext/nokogiri/xml_node_set.c
CHANGED
|
@@ -304,7 +304,7 @@ index_at(VALUE rb_self, long offset)
|
|
|
304
304
|
|
|
305
305
|
TypedData_Get_Struct(rb_self, xmlNodeSet, &xml_node_set_type, c_self);
|
|
306
306
|
|
|
307
|
-
if (offset >= c_self->nodeNr ||
|
|
307
|
+
if (offset >= c_self->nodeNr || offset < -c_self->nodeNr) {
|
|
308
308
|
return Qnil;
|
|
309
309
|
}
|
|
310
310
|
|
|
@@ -11,6 +11,15 @@ static const xmlChar *NOKOGIRI_URI = (const xmlChar *)"http://www.nokogiri.org/d
|
|
|
11
11
|
static const xmlChar *NOKOGIRI_BUILTIN_PREFIX = (const xmlChar *)"nokogiri-builtin";
|
|
12
12
|
static const xmlChar *NOKOGIRI_BUILTIN_URI = (const xmlChar *)"https://www.nokogiri.org/default_ns/ruby/builtins";
|
|
13
13
|
|
|
14
|
+
static void
|
|
15
|
+
_noko_xml_xpath_context_dmark(void *data)
|
|
16
|
+
{
|
|
17
|
+
xmlXPathContextPtr c_context = data;
|
|
18
|
+
if (c_context->doc && DOC_RUBY_OBJECT_TEST(c_context->doc)) {
|
|
19
|
+
rb_gc_mark(DOC_RUBY_OBJECT(c_context->doc));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
14
23
|
static void
|
|
15
24
|
_noko_xml_xpath_context_dfree(void *data)
|
|
16
25
|
{
|
|
@@ -21,9 +30,10 @@ _noko_xml_xpath_context_dfree(void *data)
|
|
|
21
30
|
static const rb_data_type_t _noko_xml_xpath_context_type = {
|
|
22
31
|
.wrap_struct_name = "xmlXPathContext",
|
|
23
32
|
.function = {
|
|
33
|
+
.dmark = _noko_xml_xpath_context_dmark,
|
|
24
34
|
.dfree = _noko_xml_xpath_context_dfree,
|
|
25
35
|
},
|
|
26
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
|
36
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
|
27
37
|
};
|
|
28
38
|
|
|
29
39
|
/* find a CSS class in an HTML element's `class` attribute */
|
|
@@ -133,6 +133,35 @@ rb_xslt_stylesheet_serialize(VALUE self, VALUE xmlobj)
|
|
|
133
133
|
return rval ;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
|
|
137
|
+
/*
|
|
138
|
+
* Build the C-string params array passed to xsltApplyStylesheet.
|
|
139
|
+
*
|
|
140
|
+
* Note: params[j] is a raw pointer into a Ruby string's buffer, and we do not pin the underlying
|
|
141
|
+
* VALUEs against GC compaction. This is safe (despite not pinning the VALUEs) because libxslt fully
|
|
142
|
+
* processes params (interning names, evaluating values) before template execution begins, and Ruby
|
|
143
|
+
* callbacks can only run during template execution. By the time GC compaction is reachable, libxslt
|
|
144
|
+
* no longer reads params[].
|
|
145
|
+
*/
|
|
146
|
+
typedef struct {
|
|
147
|
+
VALUE rb_param;
|
|
148
|
+
long param_len;
|
|
149
|
+
const char **params;
|
|
150
|
+
} build_xslt_params_args_t;
|
|
151
|
+
|
|
152
|
+
static VALUE
|
|
153
|
+
build_xslt_params(VALUE args_ptr)
|
|
154
|
+
{
|
|
155
|
+
build_xslt_params_args_t *args = (build_xslt_params_args_t *)args_ptr;
|
|
156
|
+
|
|
157
|
+
for (long j = 0; j < args->param_len; j++) {
|
|
158
|
+
VALUE entry = rb_ary_entry(args->rb_param, j);
|
|
159
|
+
args->params[j] = StringValueCStr(entry);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return Qnil;
|
|
163
|
+
}
|
|
164
|
+
|
|
136
165
|
/*
|
|
137
166
|
* call-seq:
|
|
138
167
|
* transform(document)
|
|
@@ -254,7 +283,7 @@ rb_xslt_stylesheet_transform(int argc, VALUE *argv, VALUE self)
|
|
|
254
283
|
xmlDocPtr c_result_document ;
|
|
255
284
|
nokogiriXsltStylesheetTuple *wrapper;
|
|
256
285
|
const char **params ;
|
|
257
|
-
long param_len
|
|
286
|
+
long param_len ;
|
|
258
287
|
int parse_error_occurred ;
|
|
259
288
|
int defensive_copy_p = 0;
|
|
260
289
|
|
|
@@ -277,10 +306,17 @@ rb_xslt_stylesheet_transform(int argc, VALUE *argv, VALUE self)
|
|
|
277
306
|
|
|
278
307
|
param_len = RARRAY_LEN(rb_param);
|
|
279
308
|
params = ruby_xcalloc((size_t)param_len + 1, sizeof(char *));
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
309
|
+
{
|
|
310
|
+
// populate params under rb_protect so that a raise from StringValueCStr
|
|
311
|
+
// (e.g. on a null byte) does not leak the params allocation.
|
|
312
|
+
build_xslt_params_args_t args = { rb_param, param_len, params };
|
|
313
|
+
int state = 0;
|
|
314
|
+
|
|
315
|
+
rb_protect(build_xslt_params, (VALUE)&args, &state);
|
|
316
|
+
if (state) {
|
|
317
|
+
ruby_xfree(params);
|
|
318
|
+
rb_jump_tag(state);
|
|
319
|
+
}
|
|
284
320
|
}
|
|
285
321
|
params[param_len] = 0 ;
|
|
286
322
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
#--
|
|
3
3
|
# DO NOT MODIFY!!!!
|
|
4
|
-
# This file is automatically generated by rex 1.0.
|
|
4
|
+
# This file is automatically generated by rex 1.0.8
|
|
5
5
|
# from lexical definition file "lib/nokogiri/css/tokenizer.rex".
|
|
6
6
|
#++
|
|
7
7
|
|
|
@@ -63,13 +63,13 @@ class Tokenizer
|
|
|
63
63
|
when (text = @ss.scan(/has\([\s]*/))
|
|
64
64
|
action { [:HAS, text] }
|
|
65
65
|
|
|
66
|
-
when (text = @ss.scan(/-?([_A-Za-z]|[^\0-\177]|(\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f]))([_A-Za-z0-9-]|[^\0-\177]|(\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f]))*\([\s]*/))
|
|
66
|
+
when (text = @ss.scan(/-?(?>[_A-Za-z]|[^\0-\177]|(\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f]))(?>[_A-Za-z0-9-]|[^\0-\177]|(\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f]))*\([\s]*/))
|
|
67
67
|
action { [:FUNCTION, text] }
|
|
68
68
|
|
|
69
|
-
when (text = @ss.scan(/-?([_A-Za-z]|[^\0-\177]|(\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f]))([_A-Za-z0-9-]|[^\0-\177]|(\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f]))*/))
|
|
69
|
+
when (text = @ss.scan(/-?(?>[_A-Za-z]|[^\0-\177]|(\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f]))(?>[_A-Za-z0-9-]|[^\0-\177]|(\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f]))*/))
|
|
70
70
|
action { [:IDENT, text] }
|
|
71
71
|
|
|
72
|
-
when (text = @ss.scan(/\#([_A-Za-z0-9-]|[^\0-\177]|(\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f]))+/))
|
|
72
|
+
when (text = @ss.scan(/\#(?>[_A-Za-z0-9-]|[^\0-\177]|(\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f]))+/))
|
|
73
73
|
action { [:HASH, text] }
|
|
74
74
|
|
|
75
75
|
when (text = @ss.scan(/[\s]*~=[\s]*/))
|
|
@@ -132,7 +132,7 @@ class Tokenizer
|
|
|
132
132
|
when (text = @ss.scan(/[\s]+/))
|
|
133
133
|
action { [:S, text] }
|
|
134
134
|
|
|
135
|
-
when (text = @ss.scan(/("([^\n\r\f"]
|
|
135
|
+
when (text = @ss.scan(/("(?>[^\n\r\f"\\]|\\?(\n|\r\n|\r|\f)|[^\0-\177]|(\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f]))*"|'(?>[^\n\r\f'\\]|\\?(\n|\r\n|\r|\f)|[^\0-\177]|(\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f]))*')/))
|
|
136
136
|
action { [:STRING, text] }
|
|
137
137
|
|
|
138
138
|
when (text = @ss.scan(/./))
|
|
@@ -11,13 +11,13 @@ macro
|
|
|
11
11
|
unicode \\[0-9A-Fa-f]{1,6}(\r\n|[\s])?
|
|
12
12
|
|
|
13
13
|
escape ({unicode}|\\[^\n\r\f0-9A-Fa-f])
|
|
14
|
-
nmchar ([_A-Za-z0-9-]|{nonascii}|{escape})
|
|
15
|
-
nmstart ([_A-Za-z]|{nonascii}|{escape})
|
|
14
|
+
nmchar (?>[_A-Za-z0-9-]|{nonascii}|{escape})
|
|
15
|
+
nmstart (?>[_A-Za-z]|{nonascii}|{escape})
|
|
16
16
|
name {nmstart}{nmchar}*
|
|
17
17
|
ident -?{name}
|
|
18
18
|
charref {nmchar}+
|
|
19
|
-
string1 "([^\n\r\f"]
|
|
20
|
-
string2 '([^\n\r\f']
|
|
19
|
+
string1 "(?>[^\n\r\f"\\]|\\?{nl}|{nonascii}|{escape})*"
|
|
20
|
+
string2 '(?>[^\n\r\f'\\]|\\?{nl}|{nonascii}|{escape})*'
|
|
21
21
|
string ({string1}|{string2})
|
|
22
22
|
|
|
23
23
|
rule
|
|
@@ -53,6 +53,14 @@ module Nokogiri
|
|
|
53
53
|
defined?(Nokogiri::LIBXML_ICONV_ENABLED) && Nokogiri::LIBXML_ICONV_ENABLED
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
+
def libxml2_has_zlib?
|
|
57
|
+
defined?(Nokogiri::LIBXML_ZLIB_ENABLED) && Nokogiri::LIBXML_ZLIB_ENABLED
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def libxml2_has_http?
|
|
61
|
+
defined?(Nokogiri::LIBXML_HTTP_ENABLED) && Nokogiri::LIBXML_HTTP_ENABLED
|
|
62
|
+
end
|
|
63
|
+
|
|
56
64
|
def libxslt_has_datetime?
|
|
57
65
|
defined?(Nokogiri::LIBXSLT_DATETIME_ENABLED) && Nokogiri::LIBXSLT_DATETIME_ENABLED
|
|
58
66
|
end
|
|
@@ -145,6 +153,8 @@ module Nokogiri
|
|
|
145
153
|
end
|
|
146
154
|
libxml["memory_management"] = Nokogiri::LIBXML_MEMORY_MANAGEMENT
|
|
147
155
|
libxml["iconv_enabled"] = libxml2_has_iconv?
|
|
156
|
+
libxml["zlib_enabled"] = libxml2_has_zlib?
|
|
157
|
+
libxml["http_enabled"] = libxml2_has_http?
|
|
148
158
|
libxml["compiled"] = compiled_libxml_version.to_s
|
|
149
159
|
libxml["loaded"] = loaded_libxml_version.to_s
|
|
150
160
|
end
|
|
@@ -85,8 +85,9 @@ module Nokogiri
|
|
|
85
85
|
read_memory(string_or_io, url, encoding, options.to_i)
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
# do xinclude processing
|
|
89
|
-
|
|
88
|
+
# do xinclude processing; the document is freshly parsed and unexposed to Ruby, so the
|
|
89
|
+
# defensive copy is unnecessary
|
|
90
|
+
doc.do_xinclude(options, safe_copy: false) if options.xinclude?
|
|
90
91
|
|
|
91
92
|
doc
|
|
92
93
|
end
|
data/lib/nokogiri/xml/node.rb
CHANGED
|
@@ -523,16 +523,67 @@ module Nokogiri
|
|
|
523
523
|
set_namespace(ns)
|
|
524
524
|
end
|
|
525
525
|
|
|
526
|
+
XINCLUDE_NAMESPACES = {
|
|
527
|
+
"xi2001" => "http://www.w3.org/2001/XInclude",
|
|
528
|
+
"xi2003" => "http://www.w3.org/2003/XInclude",
|
|
529
|
+
}.freeze
|
|
530
|
+
private_constant :XINCLUDE_NAMESPACES
|
|
531
|
+
|
|
532
|
+
# Every top-level <xi:include> in the subtree, in either XInclude namespace, excluding
|
|
533
|
+
# includes nested inside another include's fallback (libxml2 only expands those if the
|
|
534
|
+
# parent include fails).
|
|
535
|
+
XINCLUDE_QUERY =
|
|
536
|
+
"descendant-or-self::xi2001:include[not(ancestor::xi2001:include) and not(ancestor::xi2003:include)] | " \
|
|
537
|
+
"descendant-or-self::xi2003:include[not(ancestor::xi2001:include) and not(ancestor::xi2003:include)]"
|
|
538
|
+
private_constant :XINCLUDE_QUERY
|
|
539
|
+
|
|
526
540
|
###
|
|
527
|
-
#
|
|
528
|
-
#
|
|
529
|
-
#
|
|
530
|
-
|
|
541
|
+
# :call-seq:
|
|
542
|
+
# do_xinclude(options = ParseOptions::DEFAULT_XML, safe_copy: true) → self
|
|
543
|
+
# do_xinclude(options = ParseOptions::DEFAULT_XML, safe_copy: true) { |options| ... } → self
|
|
544
|
+
#
|
|
545
|
+
# Do XInclude substitution on the subtree below this node, replacing each +<xi:include>+ with
|
|
546
|
+
# the content it references.
|
|
547
|
+
#
|
|
548
|
+
# [Parameters]
|
|
549
|
+
# - +options+ (Nokogiri::XML::ParseOptions) The parser options for the substitution. (default
|
|
550
|
+
# +ParseOptions::DEFAULT_XML+)
|
|
551
|
+
#
|
|
552
|
+
# [Optional Keyword Arguments]
|
|
553
|
+
# - +safe_copy:+ (Boolean) Operate on a defensive copy of each +<xi:include>+ element, to
|
|
554
|
+
# prevent libxml2 from freeing memory that is bound to live Ruby objects. (default +true+)
|
|
555
|
+
#
|
|
556
|
+
# When +true+, each +<xi:include>+ is processed on an unwrapped copy of itself, so libxml2
|
|
557
|
+
# frees the copy while the original node is unlinked from the document and kept alive. This
|
|
558
|
+
# prevents a use-after-free when the +<xi:include>+ node, or any of its descendants or
|
|
559
|
+
# namespaces, has already been exposed to Ruby; as a consequence such a wrapped node ends up
|
|
560
|
+
# detached from the document rather than removed or converted in place.
|
|
561
|
+
#
|
|
562
|
+
# When +false+, the document is processed in place. This is faster but only safe when nothing
|
|
563
|
+
# in the subtree has been exposed to Ruby (for example, immediately after parsing), which is
|
|
564
|
+
# why Document.parse uses it.
|
|
565
|
+
#
|
|
566
|
+
# This option has no effect on the pure-Java backend, which performs XInclude substitution
|
|
567
|
+
# during parsing.
|
|
568
|
+
#
|
|
569
|
+
# [Yields]
|
|
570
|
+
# If a block is given, a Nokogiri::XML::ParseOptions object initialized from +options+ is
|
|
571
|
+
# yielded to it, which can be configured before substitution.
|
|
572
|
+
#
|
|
573
|
+
# [Returns] +self+ (Nokogiri::XML::Node)
|
|
574
|
+
def do_xinclude(options = XML::ParseOptions::DEFAULT_XML, safe_copy: true)
|
|
531
575
|
options = Nokogiri::XML::ParseOptions.new(options) if Integer === options
|
|
532
576
|
yield options if block_given?
|
|
533
577
|
|
|
534
|
-
|
|
535
|
-
|
|
578
|
+
if safe_copy && Nokogiri.uses_libxml?
|
|
579
|
+
xpath(XINCLUDE_QUERY, XINCLUDE_NAMESPACES).each do |include_node|
|
|
580
|
+
include_node.safe_process_xinclude(options.to_i)
|
|
581
|
+
end
|
|
582
|
+
else
|
|
583
|
+
process_xincludes(options.to_i)
|
|
584
|
+
end
|
|
585
|
+
|
|
586
|
+
self
|
|
536
587
|
end
|
|
537
588
|
|
|
538
589
|
alias_method :next, :next_sibling
|
|
@@ -76,12 +76,12 @@ module Nokogiri
|
|
|
76
76
|
#
|
|
77
77
|
# ⚠ This option enables entity substitution, contrary to what the name implies.
|
|
78
78
|
#
|
|
79
|
-
#
|
|
79
|
+
# 🛡 <b>It is UNSAFE to set this option</b> when parsing untrusted documents.
|
|
80
80
|
NOENT = 1 << 1
|
|
81
81
|
|
|
82
82
|
# Load external subsets. On by default for XSLT::Stylesheet.
|
|
83
83
|
#
|
|
84
|
-
#
|
|
84
|
+
# 🛡 <b>It is UNSAFE to set this option</b> when parsing untrusted documents.
|
|
85
85
|
DTDLOAD = 1 << 2
|
|
86
86
|
|
|
87
87
|
# Default DTD attributes. On by default for XSLT::Stylesheet.
|
|
@@ -111,7 +111,7 @@ module Nokogiri
|
|
|
111
111
|
# Forbid network access. On by default for XML::Document, XML::DocumentFragment,
|
|
112
112
|
# HTML4::Document, HTML4::DocumentFragment, XSLT::Stylesheet, and XML::Schema.
|
|
113
113
|
#
|
|
114
|
-
#
|
|
114
|
+
# 🛡 <b>It is UNSAFE to unset this option</b> when parsing untrusted documents.
|
|
115
115
|
NONET = 1 << 11
|
|
116
116
|
|
|
117
117
|
# Do not reuse the context dictionary. Off by default.
|
|
@@ -128,8 +128,7 @@ module Nokogiri
|
|
|
128
128
|
|
|
129
129
|
# Compact small text nodes. Off by default.
|
|
130
130
|
#
|
|
131
|
-
# ⚠ No modification of the DOM tree is allowed after parsing.
|
|
132
|
-
# modify the tree.
|
|
131
|
+
# ⚠ No modification of the DOM tree is allowed after parsing.
|
|
133
132
|
COMPACT = 1 << 16
|
|
134
133
|
|
|
135
134
|
# Parse using XML-1.0 before update 5. Off by default
|
|
@@ -140,7 +139,7 @@ module Nokogiri
|
|
|
140
139
|
|
|
141
140
|
# Relax any hardcoded limit from the parser. Off by default.
|
|
142
141
|
#
|
|
143
|
-
#
|
|
142
|
+
# 🛡 <b>It is UNSAFE to set this option</b> when parsing untrusted documents.
|
|
144
143
|
HUGE = 1 << 19
|
|
145
144
|
|
|
146
145
|
# Support line numbers up to <code>long int</code> (default is a <code>short int</code>). On
|
|
@@ -151,7 +150,12 @@ module Nokogiri
|
|
|
151
150
|
# The options mask used by default for parsing XML::Document and XML::DocumentFragment
|
|
152
151
|
DEFAULT_XML = RECOVER | NONET | BIG_LINES
|
|
153
152
|
|
|
154
|
-
#
|
|
153
|
+
# Shorthand options mask useful for parsing XSLT stylesheets:
|
|
154
|
+
# sets RECOVER, NONET, NOENT, DTDLOAD, DTDATTR, NOCDATA, BIG_LINES.
|
|
155
|
+
#
|
|
156
|
+
# 🛡 This option set includes `NOENT` and `DTDLOAD` which are unsafe for untrusted
|
|
157
|
+
# documents. <b>Do not parse untrusted XSLT stylesheets.</b> See Nokogiri::XSLT for more
|
|
158
|
+
# information.
|
|
155
159
|
DEFAULT_XSLT = RECOVER | NONET | NOENT | DTDLOAD | DTDATTR | NOCDATA | BIG_LINES
|
|
156
160
|
|
|
157
161
|
# The options mask used by default used for parsing HTML4::Document and HTML4::DocumentFragment
|
|
@@ -39,7 +39,7 @@ module Nokogiri
|
|
|
39
39
|
# of ParserContext#replace_entities. (Recall that the default value of
|
|
40
40
|
# ParserContext#replace_entities is `false`.)
|
|
41
41
|
#
|
|
42
|
-
#
|
|
42
|
+
# 🛡 <b>It is UNSAFE to set ParserContext#replace_entities to `true`</b> when parsing untrusted
|
|
43
43
|
# documents.
|
|
44
44
|
#
|
|
45
45
|
# 💡 For more information on entity types, see [Wikipedia's page on
|
|
@@ -3,15 +3,20 @@
|
|
|
3
3
|
module Nokogiri
|
|
4
4
|
module XSLT
|
|
5
5
|
###
|
|
6
|
-
# A Stylesheet represents an XSLT Stylesheet object.
|
|
7
|
-
#
|
|
8
|
-
# an XML::Document with a Stylesheet:
|
|
6
|
+
# A Stylesheet represents an XSLT Stylesheet object. Stylesheet creation is done through
|
|
7
|
+
# Nokogiri::XSLT.parse (or the convenience method Nokogiri.XSLT). Here is an example of
|
|
8
|
+
# transforming an XML::Document with a Stylesheet:
|
|
9
9
|
#
|
|
10
10
|
# doc = Nokogiri::XML(File.read('some_file.xml'))
|
|
11
11
|
# xslt = Nokogiri::XSLT(File.read('some_transformer.xslt'))
|
|
12
12
|
#
|
|
13
13
|
# xslt.transform(doc) # => Nokogiri::XML::Document
|
|
14
14
|
#
|
|
15
|
+
# 🛡 <b>This class does not support execution of untrusted stylesheets.</b> An untrusted
|
|
16
|
+
# stylesheet may consume a large amount of CPU, memory, or other system resources during
|
|
17
|
+
# transformation, and IO and file access are not restricted. See Nokogiri::XSLT for more
|
|
18
|
+
# information about the security implications of untrusted stylesheets.
|
|
19
|
+
#
|
|
15
20
|
# Many XSLT transformations include serialization behavior to emit a non-XML document. For these
|
|
16
21
|
# cases, please take care to invoke the #serialize method on the result of the transformation:
|
|
17
22
|
#
|
data/lib/nokogiri/xslt.rb
CHANGED
|
@@ -10,8 +10,14 @@ module Nokogiri
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
###
|
|
13
|
-
# See Nokogiri::XSLT::Stylesheet for creating and manipulating
|
|
14
|
-
#
|
|
13
|
+
# See Nokogiri::XSLT::Stylesheet for creating and manipulating Stylesheet objects.
|
|
14
|
+
#
|
|
15
|
+
# 🛡 <b>Do not use this module for untrusted stylesheet documents.</b> libxslt does not support
|
|
16
|
+
# safely processing untrusted stylesheets. Untrusted stylesheets may access the file system and
|
|
17
|
+
# network, consume large amounts of CPU, memory, or other system resources, and IO and file
|
|
18
|
+
# access are not restricted. Additionally, the stylesheet is parsed by libxml2 with +NOENT+ and
|
|
19
|
+
# +DTDLOAD+ enabled (see ParseOptions::DEFAULT_XSLT), meaning that <b>external entities will be
|
|
20
|
+
# resolved and external subsets will be loaded</b> during parsing.
|
|
15
21
|
module XSLT
|
|
16
22
|
class << self
|
|
17
23
|
# :call-seq:
|
|
@@ -20,6 +26,9 @@ module Nokogiri
|
|
|
20
26
|
#
|
|
21
27
|
# Parse the stylesheet in +xsl+, registering optional +modules+ as custom class handlers.
|
|
22
28
|
#
|
|
29
|
+
# 🛡 <b>Do not pass untrusted stylesheet content to this method.</b> See Nokogiri::XSLT for more
|
|
30
|
+
# information.
|
|
31
|
+
#
|
|
23
32
|
# [Parameters]
|
|
24
33
|
# - +xsl+ (String) XSL content to be parsed into a stylesheet
|
|
25
34
|
# - +modules+ (Hash<String ⇒ Class>) A hash of URI-to-handler relations for linking a
|