roda 3.51.0 → 3.52.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f935481900b15707f29c41122e9ba1101e4a1bb7b6e53ef6c7819f8e0113fb23
4
- data.tar.gz: 3f4938ea16d81085a0b9ee365f1cc8d317fbafd06674f1cf0e8dda37b70f3b05
3
+ metadata.gz: df634d0506d88725400ff1b82d04da87928761e9b65937c443e95cd0c084b18f
4
+ data.tar.gz: fd7e182f69a5f01cc33a654f2a94602aa121562c7b0e46b75c6bfb3e28b320bf
5
5
  SHA512:
6
- metadata.gz: 00b35a151be77f3ed93ee0b664ce2b77162b1f14c02194e0228ec99969194c54c4ca0ddd538e0eb8bfcb4109ea6712428b554da06d69e572aaffa4d854e76559
7
- data.tar.gz: ceb138da62c24fa2a3be1a57eda9187190f96b974483719894e0368ad47402258123d651403b373c09ff801d816cae2d0f9c88dcf154e2226fba4a864b9ed64d
6
+ metadata.gz: 9985fce952a85040aca26f103d82ae5762c0fb70d2c31ee9539bd053bbb700fcb97461114ca6c7f17f7be68eaa2a9e79e89826a54c5caad7c0004ea0d3eaefb5
7
+ data.tar.gz: baf99483bd37a9c74c38c3a28bb78d030e5107fceae437065cd7d7237db3ac106535ded55727b339898c398d6198872fbd6ec8c2be23854c88d7a908502c89a4
data/CHANGELOG CHANGED
@@ -1,3 +1,15 @@
1
+ = 3.52.0 (2022-01-14)
2
+
3
+ * Fix return value of Roda.freeze when multi_route plugin is used (jeremyevans) (#240)
4
+
5
+ * Use faster OpenSSL::Digest instead of Digest for assets plugin SRI support (jeremyevans)
6
+
7
+ * Drop development dependency on haml (jeremyevans)
8
+
9
+ * Make the path method in the path plugin handle blocks that accept keyword arguments in Ruby 3+ (adam12) (#227)
10
+
11
+ * Support typecast_params :date_parse_input_handler plugin option for handling input to date parsing methods (jeremyevans)
12
+
1
13
  = 3.51.0 (2021-12-15)
2
14
 
3
15
  * Avoid method redefinition warning in error_handler plugin in verbose warning mode (jeremyevans)
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2021 Jeremy Evans
1
+ Copyright (c) 2014-2022 Jeremy Evans
2
2
  Copyright (c) 2010-2014 Michel Martens, Damian Janowski and Cyril David
3
3
  Copyright (c) 2008-2009 Christian Neukirchen
4
4
 
@@ -0,0 +1,20 @@
1
+ = New Features
2
+
3
+ * The typecast_params plugin now supports a :date_parse_input_handler
4
+ option that will be called with all input that will be passed to
5
+ the date parsing methods. You can use this option to automatically
6
+ truncate input, if that is perferable to raising an error (which is
7
+ how recent versions of Ruby handle too-long input).
8
+
9
+ = Other Improvements
10
+
11
+ * The path helper methods added by the path plugin now support
12
+ blocks that use keyword arguments on Ruby 3+.
13
+
14
+ * The assets plugin now uses OpenSSL::Digest instead of Digest (if
15
+ available) for calculating SRI digests. This is faster on Ruby 3+,
16
+ where Digest no longer uses the faster OpenSSL::Digest automatically
17
+ if available.
18
+
19
+ * Roda.freeze now returns self when the multi_route plugin is used.
20
+ This was broken (not returning self) starting in 3.48.0.
@@ -641,9 +641,17 @@ class Roda
641
641
  # a different digest type or to return a static string if you don't
642
642
  # want to use a unique value.
643
643
  def asset_digest(content)
644
- require 'digest/sha2'
645
644
  algo = assets_opts[:sri] || :sha256
646
- ::Digest.const_get(algo.to_s.upcase).hexdigest(content)
645
+ digest = begin
646
+ require 'openssl'
647
+ ::OpenSSL::Digest
648
+ # :nocov:
649
+ rescue LoadError
650
+ require 'digest/sha2'
651
+ ::Digest
652
+ # :nocov:
653
+ end
654
+ digest.const_get(algo.to_s.upcase).hexdigest(content)
647
655
  end
648
656
  end
649
657
 
@@ -98,6 +98,7 @@ class Roda
98
98
  self::RodaRequest.named_route_regexp(k)
99
99
  end
100
100
  self::RodaRequest.instance_variable_get(:@namespaced_route_regexps).freeze
101
+ self
101
102
  end
102
103
 
103
104
  # Copy the named routes into the subclass when inheriting.
@@ -148,11 +148,17 @@ class Roda
148
148
  # Allow calling private _method to get path
149
149
  relative_path(request.script_name.to_s + send(_meth, *a, &blk))
150
150
  end
151
+ # :nocov:
152
+ ruby2_keywords(meth) if respond_to?(:ruby2_keywords, true)
153
+ # :nocov:
151
154
  elsif add_script_name
152
155
  define_method(meth) do |*a, &blk|
153
156
  # Allow calling private _method to get path
154
157
  request.script_name.to_s + send(_meth, *a, &blk)
155
158
  end
159
+ # :nocov:
160
+ ruby2_keywords(meth) if respond_to?(:ruby2_keywords, true)
161
+ # :nocov:
156
162
  else
157
163
  define_method(meth, &block)
158
164
  end
@@ -171,6 +177,9 @@ class Roda
171
177
  end
172
178
 
173
179
  define_method(url_meth, &url_block)
180
+ # :nocov:
181
+ ruby2_keywords(url_meth) if respond_to?(:ruby2_keywords, true)
182
+ # :nocov:
174
183
  end
175
184
 
176
185
  nil
@@ -265,6 +265,23 @@ class Roda
265
265
  # If you would like to skip this check and allow null bytes in param string values,
266
266
  # you can do by passing the <tt>:allow_null_bytes</tt> option when loading the plugin.
267
267
  #
268
+ # You can use the :date_parse_input_handler option to specify custom handling of date
269
+ # parsing input. Modern versions of Ruby and the date gem internally raise if the input to
270
+ # date parsing methods is too large to prevent denial of service. If you are using an
271
+ # older version of Ruby, you can use this option to enforce the same check:
272
+ #
273
+ # plugin :typecast_params, date_parse_input_handler: proc {|string|
274
+ # raise ArgumentError, "too big" if string.bytesize > 128
275
+ # string
276
+ # }
277
+ #
278
+ # You can also use this option to modify the input, such as truncating it to the first
279
+ # 128 bytes:
280
+ #
281
+ # plugin :typecast_params, date_parse_input_handler: proc {|string|
282
+ # string.b[0, 128]
283
+ # }
284
+ #
268
285
  # By design, typecast_params only deals with string keys, it is not possible to use
269
286
  # symbol keys as arguments to the conversion methods and have them converted.
270
287
  module TypecastParams
@@ -384,6 +401,14 @@ class Roda
384
401
  end
385
402
  end
386
403
 
404
+ module DateParseInputHandler
405
+ # Pass input string to date parsing through handle_date_parse_input.
406
+ def _string_parse!(klass, v)
407
+ v = handle_date_parse_input(v)
408
+ super
409
+ end
410
+ end
411
+
387
412
  # Class handling conversion of submitted parameters to desired types.
388
413
  class Params
389
414
  # Handle conversions for the given type using the given block.
@@ -999,11 +1024,16 @@ class Roda
999
1024
  when ''
1000
1025
  nil
1001
1026
  when String
1002
- klass.parse(v)
1027
+ _string_parse!(klass, v)
1003
1028
  else
1004
1029
  raise Error, "unexpected value received: #{v.inspect}"
1005
1030
  end
1006
1031
  end
1032
+
1033
+ # Handle parsing for string values passed to parse!.
1034
+ def _string_parse!(klass, v)
1035
+ klass.parse(v)
1036
+ end
1007
1037
  end
1008
1038
 
1009
1039
  # Set application-specific Params subclass unless one has been set,
@@ -1019,6 +1049,14 @@ class Roda
1019
1049
  if opts[:allow_null_bytes]
1020
1050
  app::TypecastParams.send(:include, AllowNullByte)
1021
1051
  end
1052
+ if opts[:date_parse_input_handler]
1053
+ app::TypecastParams.class_eval do
1054
+ include DateParseInputHandler
1055
+ define_method(:handle_date_parse_input, &opts[:date_parse_input_handler])
1056
+ private :handle_date_parse_input
1057
+ alias handle_date_parse_input handle_date_parse_input
1058
+ end
1059
+ end
1022
1060
  end
1023
1061
 
1024
1062
  module ClassMethods
data/lib/roda/version.rb CHANGED
@@ -4,7 +4,7 @@ class Roda
4
4
  RodaMajorVersion = 3
5
5
 
6
6
  # The minor version of Roda, updated for new feature releases of Roda.
7
- RodaMinorVersion = 51
7
+ RodaMinorVersion = 52
8
8
 
9
9
  # The patch version of Roda, updated only for bug fixes from the last
10
10
  # feature release.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.51.0
4
+ version: 3.52.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-15 00:00:00.000000000 Z
11
+ date: 2022-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -94,20 +94,6 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: haml
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: rack_csrf
113
99
  requirement: !ruby/object:Gem::Requirement
@@ -223,6 +209,7 @@ extra_rdoc_files:
223
209
  - doc/release_notes/3.5.0.txt
224
210
  - doc/release_notes/3.50.0.txt
225
211
  - doc/release_notes/3.51.0.txt
212
+ - doc/release_notes/3.52.0.txt
226
213
  - doc/release_notes/3.6.0.txt
227
214
  - doc/release_notes/3.7.0.txt
228
215
  - doc/release_notes/3.8.0.txt
@@ -281,6 +268,7 @@ files:
281
268
  - doc/release_notes/3.5.0.txt
282
269
  - doc/release_notes/3.50.0.txt
283
270
  - doc/release_notes/3.51.0.txt
271
+ - doc/release_notes/3.52.0.txt
284
272
  - doc/release_notes/3.6.0.txt
285
273
  - doc/release_notes/3.7.0.txt
286
274
  - doc/release_notes/3.8.0.txt
@@ -425,7 +413,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
425
413
  - !ruby/object:Gem::Version
426
414
  version: '0'
427
415
  requirements: []
428
- rubygems_version: 3.2.32
416
+ rubygems_version: 3.3.3
429
417
  signing_key:
430
418
  specification_version: 4
431
419
  summary: Routing tree web toolkit