rack 3.1.15 → 3.2.0
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/CHANGELOG.md +83 -3
- data/README.md +41 -20
- data/SPEC.rdoc +199 -306
- data/lib/rack/auth/abstract/request.rb +2 -0
- data/lib/rack/builder.rb +6 -0
- data/lib/rack/conditional_get.rb +4 -3
- data/lib/rack/constants.rb +1 -0
- data/lib/rack/head.rb +2 -3
- data/lib/rack/lint.rb +430 -457
- data/lib/rack/media_type.rb +6 -7
- data/lib/rack/mock_response.rb +19 -25
- data/lib/rack/multipart/parser.rb +39 -11
- data/lib/rack/multipart/uploaded_file.rb +42 -5
- data/lib/rack/query_parser.rb +41 -24
- data/lib/rack/request.rb +45 -54
- data/lib/rack/rewindable_input.rb +4 -1
- data/lib/rack/show_exceptions.rb +4 -2
- data/lib/rack/show_status.rb +0 -2
- data/lib/rack/utils.rb +14 -23
- data/lib/rack/version.rb +4 -8
- data/lib/rack.rb +0 -1
- metadata +2 -2
- data/lib/rack/logger.rb +0 -23
data/lib/rack/utils.rb
CHANGED
@@ -181,12 +181,16 @@ module Rack
|
|
181
181
|
# doesn't get monkey-patched by rails
|
182
182
|
if defined?(ERB::Escape) && ERB::Escape.instance_method(:html_escape)
|
183
183
|
define_method(:escape_html, ERB::Escape.instance_method(:html_escape))
|
184
|
+
# :nocov:
|
185
|
+
# Ruby 3.2/ERB 4.0 added ERB::Escape#html_escape, so the else
|
186
|
+
# branch cannot be hit on the current Ruby version.
|
184
187
|
else
|
185
188
|
require 'cgi/escape'
|
186
189
|
# Escape ampersands, brackets and quotes to their HTML/XML entities.
|
187
190
|
def escape_html(string)
|
188
191
|
CGI.escapeHTML(string.to_s)
|
189
192
|
end
|
193
|
+
# :nocov:
|
190
194
|
end
|
191
195
|
|
192
196
|
def select_best_encoding(available_encodings, accept_encoding)
|
@@ -254,26 +258,18 @@ module Rack
|
|
254
258
|
parse_cookies_header env[HTTP_COOKIE]
|
255
259
|
end
|
256
260
|
|
257
|
-
# A valid cookie key according to RFC2616.
|
261
|
+
# A valid cookie key according to RFC6265 and RFC2616.
|
258
262
|
# A <cookie-name> can be any US-ASCII characters, except control characters, spaces, or tabs. It also must not contain a separator character like the following: ( ) < > @ , ; : \ " / [ ] ? = { }.
|
259
263
|
VALID_COOKIE_KEY = /\A[!#$%&'*+\-\.\^_`|~0-9a-zA-Z]+\z/.freeze
|
260
264
|
private_constant :VALID_COOKIE_KEY
|
261
265
|
|
262
|
-
private def escape_cookie_key(key)
|
263
|
-
if key =~ VALID_COOKIE_KEY
|
264
|
-
key
|
265
|
-
else
|
266
|
-
warn "Cookie key #{key.inspect} is not valid according to RFC2616; it will be escaped. This behaviour is deprecated and will be removed in a future version of Rack.", uplevel: 2
|
267
|
-
escape(key)
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
266
|
# :call-seq:
|
272
267
|
# set_cookie_header(key, value) -> encoded string
|
273
268
|
#
|
274
269
|
# Generate an encoded string using the provided +key+ and +value+ suitable
|
275
270
|
# for the +set-cookie+ header according to RFC6265. The +value+ may be an
|
276
|
-
# instance of either +String+ or +Hash+.
|
271
|
+
# instance of either +String+ or +Hash+. If the cookie key is invalid (as
|
272
|
+
# defined by RFC6265), an +ArgumentError+ will be raised.
|
277
273
|
#
|
278
274
|
# If the cookie +value+ is an instance of +Hash+, it considers the following
|
279
275
|
# cookie attribute keys: +domain+, +max_age+, +expires+ (must be instance
|
@@ -281,10 +277,6 @@ module Rack
|
|
281
277
|
# details about the interpretation of these fields, consult
|
282
278
|
# [RFC6265 Section 5.2](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2).
|
283
279
|
#
|
284
|
-
# An extra cookie attribute +escape_key+ can be provided to control whether
|
285
|
-
# or not the cookie key is URL encoded. If explicitly set to +false+, the
|
286
|
-
# cookie key name will not be url encoded (escaped). The default is +true+.
|
287
|
-
#
|
288
280
|
# set_cookie_header("myname", "myvalue")
|
289
281
|
# # => "myname=myvalue"
|
290
282
|
#
|
@@ -292,9 +284,12 @@ module Rack
|
|
292
284
|
# # => "myname=myvalue; max-age=10"
|
293
285
|
#
|
294
286
|
def set_cookie_header(key, value)
|
287
|
+
unless key =~ VALID_COOKIE_KEY
|
288
|
+
raise ArgumentError, "invalid cookie key: #{key.inspect}"
|
289
|
+
end
|
290
|
+
|
295
291
|
case value
|
296
292
|
when Hash
|
297
|
-
key = escape_cookie_key(key) unless value[:escape_key] == false
|
298
293
|
domain = "; domain=#{value[:domain]}" if value[:domain]
|
299
294
|
path = "; path=#{value[:path]}" if value[:path]
|
300
295
|
max_age = "; max-age=#{value[:max_age]}" if value[:max_age]
|
@@ -316,8 +311,6 @@ module Rack
|
|
316
311
|
end
|
317
312
|
partitioned = "; partitioned" if value[:partitioned]
|
318
313
|
value = value[:value]
|
319
|
-
else
|
320
|
-
key = escape_cookie_key(key)
|
321
314
|
end
|
322
315
|
|
323
316
|
value = [value] unless Array === value
|
@@ -416,7 +409,7 @@ module Rack
|
|
416
409
|
return nil if size.zero?
|
417
410
|
return nil unless http_range && http_range =~ /bytes=([^;]+)/
|
418
411
|
ranges = []
|
419
|
-
$1.split(
|
412
|
+
$1.split(/,[ \t]*/).each do |range_spec|
|
420
413
|
return nil unless range_spec.include?('-')
|
421
414
|
range = range_spec.split('-')
|
422
415
|
r0, r1 = range[0], range[1]
|
@@ -592,11 +585,9 @@ module Rack
|
|
592
585
|
fallback_code = OBSOLETE_SYMBOLS_TO_STATUS_CODES.fetch(status) { raise ArgumentError, "Unrecognized status code #{status.inspect}" }
|
593
586
|
message = "Status code #{status.inspect} is deprecated and will be removed in a future version of Rack."
|
594
587
|
if canonical_symbol = OBSOLETE_SYMBOL_MAPPINGS[status]
|
595
|
-
|
596
|
-
# For now, let's not emit any warning when there is a mapping.
|
597
|
-
else
|
598
|
-
warn message, uplevel: 3
|
588
|
+
message = "#{message} Please use #{canonical_symbol.inspect} instead."
|
599
589
|
end
|
590
|
+
warn message, uplevel: 3
|
600
591
|
fallback_code
|
601
592
|
end
|
602
593
|
else
|
data/lib/rack/version.rb
CHANGED
@@ -5,17 +5,13 @@
|
|
5
5
|
# Rack is freely distributable under the terms of an MIT-style license.
|
6
6
|
# See MIT-LICENSE or https://opensource.org/licenses/MIT.
|
7
7
|
|
8
|
-
# The Rack main module, serving as a namespace for all core Rack
|
9
|
-
# modules and classes.
|
10
|
-
#
|
11
|
-
# All modules meant for use in your application are <tt>autoload</tt>ed here,
|
12
|
-
# so it should be enough just to <tt>require 'rack'</tt> in your code.
|
13
|
-
|
14
8
|
module Rack
|
15
|
-
|
9
|
+
VERSION = "3.2.0"
|
10
|
+
|
11
|
+
RELEASE = VERSION
|
16
12
|
|
17
13
|
# Return the Rack release as a dotted string.
|
18
14
|
def self.release
|
19
|
-
|
15
|
+
VERSION
|
20
16
|
end
|
21
17
|
end
|
data/lib/rack.rb
CHANGED
@@ -34,7 +34,6 @@ module Rack
|
|
34
34
|
autoload :Headers, "rack/headers"
|
35
35
|
autoload :Lint, "rack/lint"
|
36
36
|
autoload :Lock, "rack/lock"
|
37
|
-
autoload :Logger, "rack/logger"
|
38
37
|
autoload :MediaType, "rack/media_type"
|
39
38
|
autoload :MethodOverride, "rack/method_override"
|
40
39
|
autoload :Mime, "rack/mime"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leah Neukirchen
|
@@ -107,7 +107,6 @@ files:
|
|
107
107
|
- lib/rack/headers.rb
|
108
108
|
- lib/rack/lint.rb
|
109
109
|
- lib/rack/lock.rb
|
110
|
-
- lib/rack/logger.rb
|
111
110
|
- lib/rack/media_type.rb
|
112
111
|
- lib/rack/method_override.rb
|
113
112
|
- lib/rack/mime.rb
|
@@ -142,6 +141,7 @@ metadata:
|
|
142
141
|
changelog_uri: https://github.com/rack/rack/blob/main/CHANGELOG.md
|
143
142
|
documentation_uri: https://rubydoc.info/github/rack/rack
|
144
143
|
source_code_uri: https://github.com/rack/rack
|
144
|
+
rubygems_mfa_required: 'true'
|
145
145
|
rdoc_options: []
|
146
146
|
require_paths:
|
147
147
|
- lib
|
data/lib/rack/logger.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'logger'
|
4
|
-
require_relative 'constants'
|
5
|
-
|
6
|
-
warn "Rack::Logger is deprecated and will be removed in Rack 3.2.", uplevel: 1
|
7
|
-
|
8
|
-
module Rack
|
9
|
-
# Sets up rack.logger to write to rack.errors stream
|
10
|
-
class Logger
|
11
|
-
def initialize(app, level = ::Logger::INFO)
|
12
|
-
@app, @level = app, level
|
13
|
-
end
|
14
|
-
|
15
|
-
def call(env)
|
16
|
-
logger = ::Logger.new(env[RACK_ERRORS])
|
17
|
-
logger.level = @level
|
18
|
-
|
19
|
-
env[RACK_LOGGER] = logger
|
20
|
-
@app.call(env)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|