nokogiri 1.19.2-aarch64-linux-gnu → 1.19.3-aarch64-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f749210d7724d8084e0588681c74c8a3b06d827556fd51ab7005af47fa94383c
4
- data.tar.gz: e67bd0727cf6551ac08d6b0b373b9b5fed5878dd7793f8a92e6bd282c6c7c367
3
+ metadata.gz: ef67c67345d63d916b9f8785718c985d0900a409864833df3d3a7e76ca9a7943
4
+ data.tar.gz: 6c055b94cee733a2d0c5b6879b54765864431254a8d66ffd862fc56f6370384c
5
5
  SHA512:
6
- metadata.gz: 0de1fdf5a00c5f9e44c52822989c0adcfbd4ede8cdf0ef05cc5b2186b799820069cfe4ab48442b2a3b4e5c17d5411299840615eea029fec602649804e35564b0
7
- data.tar.gz: b6c6dd937024298ca3bcba4889dc07491a8dbfaa9a32dbe1b486ef096d83c71b15cda5d29c25f5da3eada733ce228a23841f4529259d821bdb66293267b16ae5
6
+ metadata.gz: 17f5baed7e4e7e3e4805d7a315d525e460826fbc9f2791fd3d2410c9efed45b30f98da5252f671ea61c066b8d811272ac31fe29457ec975493c6e6885c028eb4
7
+ data.tar.gz: 2fe92e99719ad08363137065b3a4a635ccf6a4ba1149c208e9f52800bb7e35c76a7c29191e74e3711cbffacf9751921055b56821443b6dc0d52c4afe3a7471e2
@@ -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, j ;
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
- for (j = 0 ; j < param_len ; j++) {
281
- VALUE entry = rb_ary_entry(rb_param, j);
282
- const char *ptr = StringValueCStr(entry);
283
- params[j] = ptr;
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.7
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"]|(\n|\r\n|\r|\f)|[^\0-\177]|(\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f]))*(?<!\\)(?:\\{2})*"|'([^\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]))*(?<!\\)(?:\\{2})*')/))
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"]|{nl}|{nonascii}|{escape})*(?<!\\)(?:\\{2})*"
20
- string2 '([^\n\r\f']|{nl}|{nonascii}|{escape})*(?<!\\)(?:\\{2})*'
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Nokogiri
4
4
  # The version of Nokogiri you are using
5
- VERSION = "1.19.2"
5
+ VERSION = "1.19.3"
6
6
  end
@@ -76,12 +76,12 @@ module Nokogiri
76
76
  #
77
77
  # ⚠ This option enables entity substitution, contrary to what the name implies.
78
78
  #
79
- # <b>It is UNSAFE to set this option</b> when parsing untrusted documents.
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
- # <b>It is UNSAFE to set this option</b> when parsing untrusted documents.
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
- # <b>It is UNSAFE to unset this option</b> when parsing untrusted documents.
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. libxml2 may crash if you try to
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
- # <b>It is UNSAFE to set this option</b> when parsing untrusted documents.
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
- # The options mask used by default used for parsing XSLT::Stylesheet
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
- # <b>It is UNSAFE to set ParserContext#replace_entities to `true`</b> when parsing untrusted
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. Stylesheet creation
7
- # is done through Nokogiri.XSLT. Here is an example of transforming
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
- # Stylesheet object.
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.2
4
+ version: 1.19.3
5
5
  platform: aarch64-linux-gnu
6
6
  authors:
7
7
  - Mike Dalessio