rack 3.1.3 → 3.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +63 -17
- data/SPEC.rdoc +1 -1
- data/lib/rack/lint.rb +4 -2
- data/lib/rack/mock_request.rb +4 -14
- data/lib/rack/multipart/parser.rb +0 -1
- data/lib/rack/request.rb +14 -2
- data/lib/rack/response.rb +17 -12
- data/lib/rack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d973a8acf0ebcdea8f2cb7930d3f0417cdc32a1aeddb31c5f140357b7f968e3
|
4
|
+
data.tar.gz: a480d18cd351082f259cca12af557d9245717436135d87769584f53467d08912
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35d4ed80330dc0ac3484cbe7ba1208a27b5fc6e214873072bac0d9302bb84b06ffb93ff52abfa007298e2b305f7ffa19dde4e97afd9e58ac4ccefd8b33e62dbc
|
7
|
+
data.tar.gz: e278e7a0174d95775c006a51ef391d9bc968f7fb52bc9b4fdcb5d30859a06578946cf1a255f29349d00e0df87543d317d7590afe98fd07875d10f343603938ca
|
data/CHANGELOG.md
CHANGED
@@ -2,52 +2,98 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file. For info on how to format all future additions to this file please reference [Keep A Changelog](https://keepachangelog.com/en/1.0.0/).
|
4
4
|
|
5
|
+
## [3.1.7] - 2024-07-11
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
|
9
|
+
- Do not remove escaped opening/closing quotes for content-disposition filenames. ([#2229](https://github.com/rack/rack/pull/2229), [@jeremyevans])
|
10
|
+
- Fix encoding setting for non-binary IO-like objects in MockRequest#env_for. ([#2227](https://github.com/rack/rack/pull/2227), [@jeremyevans])
|
11
|
+
- `Rack::Response` should not generate invalid `content-length` header. ([#2219](https://github.com/rack/rack/pull/2219), [@ioquatix])
|
12
|
+
- Allow empty PATH_INFO. ([#2214](https://github.com/rack/rack/pull/2214), [@ioquatix])
|
13
|
+
|
14
|
+
## [3.1.6] - 2024-07-03
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
18
|
+
- Fix several edge cases in `Rack::Request#parse_http_accept_header`'s implementation. ([#2226](https://github.com/rack/rack/pull/2226), [@ioquatix])
|
19
|
+
|
20
|
+
## [3.1.5] - 2024-07-02
|
21
|
+
|
22
|
+
### Security
|
23
|
+
|
24
|
+
- Fix potential ReDoS attack in `Rack::Request#parse_http_accept_header`. ([GHSA-cj83-2ww7-mvq7](https://github.com/rack/rack/security/advisories/GHSA-cj83-2ww7-mvq7), [@dwisiswant0](https://github.com/dwisiswant0))
|
25
|
+
|
26
|
+
## [3.1.4] - 2024-06-22
|
27
|
+
|
28
|
+
### Fixed
|
29
|
+
|
30
|
+
- Fix `Rack::Lint` matching some paths incorrectly as authority form. ([#2220](https://github.com/rack/rack/pull/2220), [@ioquatix])
|
31
|
+
|
5
32
|
## [3.1.3] - 2024-06-12
|
6
33
|
|
7
34
|
### Fixed
|
8
35
|
|
9
36
|
- Fix passing non-strings to `Rack::Utils.escape_html`. ([#2202](https://github.com/rack/rack/pull/2202), [@earlopain])
|
10
|
-
- `Rack::MockResponse` gracefully handles empty cookies ([#2203](https://github.com/rack/rack/pull/2203) [@wynksaiddestroy]
|
37
|
+
- `Rack::MockResponse` gracefully handles empty cookies ([#2203](https://github.com/rack/rack/pull/2203) [@wynksaiddestroy])
|
11
38
|
|
12
39
|
## [3.1.2] - 2024-06-11
|
13
40
|
|
14
|
-
## Changed
|
15
|
-
|
16
41
|
- `Rack::Response` will take in to consideration chunked encoding responses ([#2204](https://github.com/rack/rack/pull/2204), [@tenderlove])
|
17
42
|
|
18
43
|
## [3.1.1] - 2024-06-11
|
19
44
|
|
20
|
-
- Oops
|
45
|
+
- Oops! I shouldn't have shipped that
|
21
46
|
|
22
47
|
## [3.1.0] - 2024-06-11
|
23
48
|
|
49
|
+
:warning: **This release includes several breaking changes.** Refer to the **Removed** section below for the list of deprecated methods that have been removed in this release.
|
50
|
+
|
51
|
+
Rack v3.1 is primarily a maintenance release that removes features deprecated in Rack v3.0. Alongside these removals, there are several improvements to the Rack SPEC, mainly focused on enhancing input and output handling. These changes aim to make Rack more efficient and align better with the requirements of server implementations and relevant HTTP specifications.
|
52
|
+
|
24
53
|
### SPEC Changes
|
25
54
|
|
26
|
-
- `rack.input` is now optional. ([#1997](https://github.com/rack/rack/pull/1997), [@ioquatix])
|
27
|
-
- `PATH_INFO` is now validated according to the HTTP/1.1 specification. ([#2117](https://github.com/rack/rack/pull/2117), [@ioquatix])
|
28
|
-
- `
|
55
|
+
- `rack.input` is now optional. ([#1997](https://github.com/rack/rack/pull/1997), [#2018](https://github.com/rack/rack/pull/2018), [@ioquatix])
|
56
|
+
- `PATH_INFO` is now validated according to the HTTP/1.1 specification. ([#2117](https://github.com/rack/rack/pull/2117), [#2181](https://github.com/rack/rack/pull/2181), [@ioquatix])
|
57
|
+
- `OPTIONS *` is now accepted. ([#2114](https://github.com/rack/rack/pull/2114), [@doriantaylor](https://github.com/doriantaylor))
|
58
|
+
- Introduce optional `rack.protocol` request and response header for handling connection upgrades. ([#1954](https://github.com/rack/rack/pull/1954), [@ioquatix])
|
29
59
|
|
30
60
|
### Added
|
31
61
|
|
62
|
+
- Introduce `Rack::Multipart::MissingInputError` for improved handling of missing input in `#parse_multipart`. ([#2018](https://github.com/rack/rack/pull/2018), [@ioquatix])
|
32
63
|
- Introduce `module Rack::BadRequest` which is included in multipart and query parser errors. ([#2019](https://github.com/rack/rack/pull/2019), [@ioquatix])
|
33
|
-
- Add `.mjs` MIME type ([#2057](https://github.com/rack/rack/pull/2057), [@axilleas])
|
34
|
-
- `set_cookie_header` utility now supports the `partitioned` cookie attribute. This is required by Chrome in some embedded contexts. ([#2131](https://github.com/rack/rack/pull/2131), [@flavio-b])
|
35
|
-
- `rack.early_hints`
|
64
|
+
- Add `.mjs` MIME type ([#2057](https://github.com/rack/rack/pull/2057), [@axilleas](https://github.com/axilleas))
|
65
|
+
- `set_cookie_header` utility now supports the `partitioned` cookie attribute. This is required by Chrome in some embedded contexts. ([#2131](https://github.com/rack/rack/pull/2131), [@flavio-b](https://github.com/flavio-b))
|
66
|
+
- Introduce `rack.early_hints` for sending `103 Early Hints` informational responses. ([#1831](https://github.com/rack/rack/pull/1831), [@casperisfine](https://github.com/casperisfine), [@jeremyevans])
|
36
67
|
|
37
68
|
### Changed
|
38
69
|
|
39
|
-
-
|
40
|
-
- MIME type for JavaScript files (`.js`) changed from `application/javascript` to `text/javascript` ([`1bd0f15`](https://github.com/rack/rack/commit/1bd0f1597d8f4a90d47115f3e156a8ce7870c9c8))
|
70
|
+
- MIME type for JavaScript files (`.js`) changed from `application/javascript` to `text/javascript` ([`1bd0f15`](https://github.com/rack/rack/commit/1bd0f1597d8f4a90d47115f3e156a8ce7870c9c8), [@ioquatix])
|
41
71
|
- Update MIME types associated to `.ttf`, `.woff`, `.woff2` and `.otf` extensions to use mondern `font/*` types. ([#2065](https://github.com/rack/rack/pull/2065), [@davidstosik])
|
42
72
|
- `Rack::Utils.escape_html` is now delegated to `CGI.escapeHTML`. `'` is escaped to `#39;` instead of `#x27;`. (decimal vs hexadecimal) ([#2099](https://github.com/rack/rack/pull/2099), [@JunichiIto](https://github.com/JunichiIto))
|
73
|
+
- Clarify use of `@buffered` and only update `content-length` when `Rack::Response#finish` is invoked. ([#2149](https://github.com/rack/rack/pull/2149), [@ioquatix])
|
74
|
+
|
75
|
+
### Deprecated
|
76
|
+
|
77
|
+
- Deprecate automatic cache invalidation in `Request#{GET,POST}` ([#2073](https://github.com/rack/rack/pull/2073), [@jeremyevans])
|
43
78
|
- Only cookie keys that are not valid according to the HTTP specifications are escaped. We are planning to deprecate this behaviour, so now a deprecation message will be emitted in this case. In the future, invalid cookie keys may not be accepted. ([#2191](https://github.com/rack/rack/pull/2191), [@ioquatix])
|
79
|
+
- `Rack::Logger` is deprecated. ([#2197](https://github.com/rack/rack/pull/2197), [@ioquatix])
|
80
|
+
- Add fallback lookup and deprecation warning for obsolete status symbols. ([#2137](https://github.com/rack/rack/pull/2137), [@wtn](https://github.com/wtn))
|
81
|
+
- Deprecate `Rack::Request#values_at`, use `request.params.values_at` instead ([#2183](https://github.com/rack/rack/pull/2183), [@ioquatix])
|
44
82
|
|
45
83
|
### Removed
|
46
84
|
|
47
|
-
- Remove
|
48
|
-
-
|
49
|
-
-
|
50
|
-
- `Rack::
|
85
|
+
- Remove deprecated `Rack::Auth::Digest` with no replacement. ([#1966](https://github.com/rack/rack/pull/1966), [@ioquatix])
|
86
|
+
- Remove deprecated `Rack::Cascade::NotFound` with no replacement. ([#1966](https://github.com/rack/rack/pull/1966), [@ioquatix])
|
87
|
+
- Remove deprecated `Rack::Chunked` with no replacement. ([#1966](https://github.com/rack/rack/pull/1966), [@ioquatix])
|
88
|
+
- Remove deprecated `Rack::File`, use `Rack::Files` instead. ([#1966](https://github.com/rack/rack/pull/1966), [@ioquatix])
|
89
|
+
- Remove deprecated `Rack::QueryParser` `key_space_limit` parameter with no replacement. ([#1966](https://github.com/rack/rack/pull/1966), [@ioquatix])
|
90
|
+
- Remove deprecated `Rack::Response#header`, use `Rack::Response#headers` instead. ([#1966](https://github.com/rack/rack/pull/1966), [@ioquatix])
|
91
|
+
- Remove deprecated cookie methods from `Rack::Utils`: `add_cookie_to_header`, `make_delete_cookie_header`, `add_remove_cookie_to_header`. ([#1966](https://github.com/rack/rack/pull/1966), [@ioquatix])
|
92
|
+
- Remove deprecated `Rack::Utils::HeaderHash`. ([#1966](https://github.com/rack/rack/pull/1966), [@ioquatix])
|
93
|
+
- Remove deprecated `Rack::VERSION`, `Rack::VERSION_STRING`, `Rack.version`, use `Rack.release` instead. ([#1966](https://github.com/rack/rack/pull/1966), [@ioquatix])
|
94
|
+
- Remove non-standard status codes 306, 509, & 510 and update descriptions for 413, 422, & 451. ([#2137](https://github.com/rack/rack/pull/2137), [@wtn](https://github.com/wtn))
|
95
|
+
- Remove any dependency on `transfer-encoding: chunked`. ([#2195](https://github.com/rack/rack/pull/2195), [@ioquatix])
|
96
|
+
- Remove deprecated `Rack::Request#[]`, use `request.params[key]` instead ([#2183](https://github.com/rack/rack/pull/2183), [@ioquatix])
|
51
97
|
|
52
98
|
### Fixed
|
53
99
|
|
@@ -125,7 +171,7 @@ All notable changes to this project will be documented in this file. For info on
|
|
125
171
|
|
126
172
|
- `Rack::URLMap` uses non-deprecated form of `Regexp.new`. ([#1998](https://github.com/rack/rack/pull/1998), [@weizheheng](https://github.com/weizheheng))
|
127
173
|
|
128
|
-
## [3.0.2] -2022-12-05
|
174
|
+
## [3.0.2] - 2022-12-05
|
129
175
|
|
130
176
|
### Fixed
|
131
177
|
|
data/SPEC.rdoc
CHANGED
@@ -130,7 +130,7 @@ There are the following restrictions:
|
|
130
130
|
* There may be a valid early hints callback in <tt>rack.early_hints</tt>
|
131
131
|
* The <tt>REQUEST_METHOD</tt> must be a valid token.
|
132
132
|
* The <tt>SCRIPT_NAME</tt>, if non-empty, must start with <tt>/</tt>
|
133
|
-
* The <tt>PATH_INFO</tt>, if provided, must be a valid request target.
|
133
|
+
* The <tt>PATH_INFO</tt>, if provided, must be a valid request target or an empty string.
|
134
134
|
* Only <tt>OPTIONS</tt> requests may have <tt>PATH_INFO</tt> set to <tt>*</tt> (asterisk-form).
|
135
135
|
* Only <tt>CONNECT</tt> requests may have <tt>PATH_INFO</tt> set to an authority (authority-form). Note that in HTTP/2+, the authority-form is not a valid request target.
|
136
136
|
* <tt>CONNECT</tt> and <tt>OPTIONS</tt> requests must not have <tt>PATH_INFO</tt> set to a URI (absolute-form).
|
data/lib/rack/lint.rb
CHANGED
@@ -13,7 +13,7 @@ module Rack
|
|
13
13
|
class Lint
|
14
14
|
REQUEST_PATH_ORIGIN_FORM = /\A\/[^#]*\z/
|
15
15
|
REQUEST_PATH_ABSOLUTE_FORM = /\A#{URI::DEFAULT_PARSER.make_regexp}\z/
|
16
|
-
REQUEST_PATH_AUTHORITY_FORM = /\A
|
16
|
+
REQUEST_PATH_AUTHORITY_FORM = /\A[^\/:]+:\d+\z/
|
17
17
|
REQUEST_PATH_ASTERISK_FORM = '*'
|
18
18
|
|
19
19
|
def initialize(app)
|
@@ -361,7 +361,7 @@ module Rack
|
|
361
361
|
raise LintError, "SCRIPT_NAME must start with /"
|
362
362
|
end
|
363
363
|
|
364
|
-
## * The <tt>PATH_INFO</tt>, if provided, must be a valid request target.
|
364
|
+
## * The <tt>PATH_INFO</tt>, if provided, must be a valid request target or an empty string.
|
365
365
|
if env.include?(PATH_INFO)
|
366
366
|
case env[PATH_INFO]
|
367
367
|
when REQUEST_PATH_ASTERISK_FORM
|
@@ -381,6 +381,8 @@ module Rack
|
|
381
381
|
end
|
382
382
|
when REQUEST_PATH_ORIGIN_FORM
|
383
383
|
## * Otherwise, <tt>PATH_INFO</tt> must start with a <tt>/</tt> and must not include a fragment part starting with '#' (origin-form).
|
384
|
+
when ""
|
385
|
+
# Empty string is okay.
|
384
386
|
else
|
385
387
|
raise LintError, "PATH_INFO must start with a '/' and must not include a fragment part starting with '#' (origin-form)"
|
386
388
|
end
|
data/lib/rack/mock_request.rb
CHANGED
@@ -139,23 +139,13 @@ module Rack
|
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
|
-
|
143
|
-
if String ===
|
144
|
-
rack_input = StringIO.new(
|
145
|
-
rack_input.set_encoding(Encoding::BINARY)
|
146
|
-
else
|
147
|
-
if input.respond_to?(:encoding) && input.encoding != Encoding::BINARY
|
148
|
-
warn "input encoding not binary", uplevel: 1
|
149
|
-
if input.respond_to?(:set_encoding)
|
150
|
-
input.set_encoding(Encoding::BINARY)
|
151
|
-
else
|
152
|
-
raise ArgumentError, "could not coerce input to binary encoding"
|
153
|
-
end
|
154
|
-
end
|
155
|
-
rack_input = input
|
142
|
+
rack_input = opts[:input]
|
143
|
+
if String === rack_input
|
144
|
+
rack_input = StringIO.new(rack_input)
|
156
145
|
end
|
157
146
|
|
158
147
|
if rack_input
|
148
|
+
rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding)
|
159
149
|
env[RACK_INPUT] = rack_input
|
160
150
|
|
161
151
|
env["CONTENT_LENGTH"] ||= env[RACK_INPUT].size.to_s if env[RACK_INPUT].respond_to?(:size)
|
data/lib/rack/request.rb
CHANGED
@@ -642,14 +642,26 @@ module Rack
|
|
642
642
|
end
|
643
643
|
|
644
644
|
def parse_http_accept_header(header)
|
645
|
-
|
646
|
-
|
645
|
+
# It would be nice to use filter_map here, but it's Ruby 2.7+
|
646
|
+
parts = header.to_s.split(',')
|
647
|
+
|
648
|
+
parts.map! do |part|
|
649
|
+
part.strip!
|
650
|
+
next if part.empty?
|
651
|
+
|
652
|
+
attribute, parameters = part.split(';', 2)
|
653
|
+
attribute.strip!
|
654
|
+
parameters&.strip!
|
647
655
|
quality = 1.0
|
648
656
|
if parameters and /\Aq=([\d.]+)/ =~ parameters
|
649
657
|
quality = $1.to_f
|
650
658
|
end
|
651
659
|
[attribute, quality]
|
652
660
|
end
|
661
|
+
|
662
|
+
parts.compact!
|
663
|
+
|
664
|
+
parts
|
653
665
|
end
|
654
666
|
|
655
667
|
# Get an array of values set in the RFC 7239 `Forwarded` request header.
|
data/lib/rack/response.rb
CHANGED
@@ -72,7 +72,8 @@ module Rack
|
|
72
72
|
if body.nil?
|
73
73
|
@body = []
|
74
74
|
@buffered = true
|
75
|
-
|
75
|
+
# Body is unspecified - it may be a buffered response, or it may be a HEAD response.
|
76
|
+
@length = nil
|
76
77
|
elsif body.respond_to?(:to_str)
|
77
78
|
@body = [body]
|
78
79
|
@buffered = true
|
@@ -80,7 +81,7 @@ module Rack
|
|
80
81
|
else
|
81
82
|
@body = body
|
82
83
|
@buffered = nil # undetermined as of yet.
|
83
|
-
@length =
|
84
|
+
@length = nil
|
84
85
|
end
|
85
86
|
|
86
87
|
yield self if block_given?
|
@@ -110,14 +111,15 @@ module Rack
|
|
110
111
|
close
|
111
112
|
return [@status, @headers, []]
|
112
113
|
else
|
113
|
-
if @length && @length > 0 && !chunked?
|
114
|
-
set_header CONTENT_LENGTH, @length.to_s
|
115
|
-
end
|
116
|
-
|
117
114
|
if block_given?
|
115
|
+
# We don't add the content-length here as the user has provided a block that can #write additional chunks to the body.
|
118
116
|
@block = block
|
119
117
|
return [@status, @headers, self]
|
120
118
|
else
|
119
|
+
# If we know the length of the body, set the content-length header... except if we are chunked? which is a legacy special case where the body might already be encoded and thus the actual encoded body length and the content-length are likely to be different.
|
120
|
+
if @length && !chunked?
|
121
|
+
@headers[CONTENT_LENGTH] = @length.to_s
|
122
|
+
end
|
121
123
|
return [@status, @headers, @body]
|
122
124
|
end
|
123
125
|
end
|
@@ -135,7 +137,9 @@ module Rack
|
|
135
137
|
end
|
136
138
|
end
|
137
139
|
|
138
|
-
# Append to
|
140
|
+
# Append a chunk to the response body.
|
141
|
+
#
|
142
|
+
# Converts the response into a buffered response if it wasn't already.
|
139
143
|
#
|
140
144
|
# NOTE: Do not mix #write and direct #body access!
|
141
145
|
#
|
@@ -336,16 +340,13 @@ module Rack
|
|
336
340
|
# Turn the user supplied body into a buffered array:
|
337
341
|
body = @body
|
338
342
|
@body = Array.new
|
339
|
-
@
|
343
|
+
@buffered = true
|
340
344
|
|
341
345
|
body.each do |part|
|
342
346
|
@writer.call(part.to_s)
|
343
347
|
end
|
344
348
|
|
345
349
|
body.close if body.respond_to?(:close)
|
346
|
-
|
347
|
-
# We have converted the body into an Array:
|
348
|
-
@buffered = true
|
349
350
|
else
|
350
351
|
# We don't know how to buffer the user-supplied body:
|
351
352
|
@buffered = false
|
@@ -359,7 +360,11 @@ module Rack
|
|
359
360
|
chunk = chunk.dup unless chunk.frozen?
|
360
361
|
@body << chunk
|
361
362
|
|
362
|
-
@length
|
363
|
+
if @length
|
364
|
+
@length += chunk.bytesize
|
365
|
+
elsif @buffered
|
366
|
+
@length = chunk.bytesize
|
367
|
+
end
|
363
368
|
|
364
369
|
return chunk
|
365
370
|
end
|
data/lib/rack/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leah Neukirchen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|