rack 3.2.7 → 3.2.9
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 -0
- data/lib/rack/directory.rb +2 -1
- data/lib/rack/multipart/parser.rb +89 -13
- data/lib/rack/multipart/uploaded_file.rb +1 -0
- data/lib/rack/query_parser.rb +21 -7
- data/lib/rack/request.rb +5 -2
- data/lib/rack/static.rb +1 -1
- data/lib/rack/version.rb +1 -1
- 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: 525ce504d772e1970a38da54295bca3e708d2064c817a36b43354b4fe1f3f5f6
|
|
4
|
+
data.tar.gz: 216bab19d15bb18906f9754ccae2f815e3f592e4c10a0155800d7d9fd2f6112c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4cae1db3881df0d79caa750578e2620cccd51aed3e8387554609ed05429ad7f9179313d19bb7738f5163dad67020aa520af0fa6c2c282a3f5683574078eaee11
|
|
7
|
+
data.tar.gz: 6adb94f5d1df18c3f0c4cd33c7c34caf3038473d04867c3e7373fcfd29ccabfd522d4fc87346530938594aeb3f06b926eee5b8c34053186f02f3c75f74af5ca4
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,37 @@
|
|
|
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.2.9] - 2026-11-20
|
|
6
|
+
|
|
7
|
+
### Security
|
|
8
|
+
|
|
9
|
+
- [GHSA-r243-pfwh-7rpx](https://github.com/advisories/GHSA-r243-pfwh-7rpx) Multipart boundary was extracted by substring match rather than parameter parsing, allowing parser differentials and WAF bypass.
|
|
10
|
+
- [GHSA-58mf-c3jj-277p](https://github.com/advisories/GHSA-58mf-c3jj-277p) Multipart parser searched the load path for every unknown part `charset`, allowing denial of service via CPU exhaustion.
|
|
11
|
+
- [GHSA-mhj6-xc86-54m8](https://github.com/advisories/GHSA-mhj6-xc86-54m8) `Rack::Directory` listed directories outside the root when `..` followed a symbolic link.
|
|
12
|
+
- [GHSA-frgv-948x-h96g](https://github.com/advisories/GHSA-frgv-948x-h96g) `Rack::Multipart::Parser` did not unfold a folded `Content-ID` header, preserving CRLF in the parsed parameter name.
|
|
13
|
+
- [GHSA-f7cc-57h7-qrcg](https://github.com/advisories/GHSA-f7cc-57h7-qrcg) `Rack::QueryParser` separator pattern allocated about 48 bytes per space after `&`, and nested parameter name splitting about 48 bytes per bracket, allowing denial of service via memory amplification. `DEFAULT_SEP` and the `COMMON_SEP` entries for `&` and `;` are now Strings rather than Regexps.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- The multipart `Content-Type` header is now parsed according to RFC 9110. An unquoted `boundary` containing characters outside the token grammar (such as `=`, `/`, `:`, `?`, parentheses, or spaces), or parameters not separated by `;`, now raise `Rack::Multipart::Error` instead of being accepted. Quoted boundaries are unaffected. ([@jeremyevans](https://github.com/jeremyevans), [@tenderlove](https://github.com/tenderlove))
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- `Rack::Multipart` no longer raises `TypeError` for a part with `charset=internal` when no default internal encoding is set; the part is treated as binary.
|
|
22
|
+
|
|
23
|
+
## [3.2.8] - 2026-10-30
|
|
24
|
+
|
|
25
|
+
### Security
|
|
26
|
+
|
|
27
|
+
- [GHSA-5v64-555j-wjxm](https://github.com/advisories/GHSA-5v64-555j-wjxm) Multipart parser retains parsed data in its scan buffer, allowing denial of service via memory exhaustion.
|
|
28
|
+
- [GHSA-wvg4-6p58-3gh3](https://github.com/advisories/GHSA-wvg4-6p58-3gh3) `Rack::Static` header rules were matched against an unnormalized path, allowing dot segments to bypass them.
|
|
29
|
+
- [GHSA-2j8w-xcrc-x985](https://github.com/advisories/GHSA-2j8w-xcrc-x985) `Rack::Request#host_with_port`, `#base_url`, and `#url` returned the raw authority when it was invalid; `host_with_port` now returns `nil` in that case.
|
|
30
|
+
- [GHSA-p8x9-v4hv-2w4g](https://github.com/advisories/GHSA-p8x9-v4hv-2w4g) Multipart requests with more than one `boundary` parameter were accepted when the first value was empty or began with a quote, semicolon, or comma, bypassing the guard added for CVE-2026-26961.
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- `Rack::Multipart::UploadedFile` now delegates keyword arguments to the wrapped tempfile. Calls such as `uploaded_file.readlines(chomp: true)` raised `TypeError` on Ruby 3.0+. ([#2481](https://github.com/rack/rack/issues/2481), [#2501](https://github.com/rack/rack/pull/2501), [@SeanLF](https://github.com/SeanLF))
|
|
35
|
+
|
|
5
36
|
## [3.2.7] - 2026-08-13
|
|
6
37
|
|
|
7
38
|
### Fixed
|
|
@@ -115,6 +146,33 @@ This release continues Rack's evolution toward a cleaner, more efficient foundat
|
|
|
115
146
|
- `SERVER_NAME` and `HTTP_HOST` are now more strictly validated according to the relevant specifications. ([#2298](https://github.com/rack/rack/pull/2298), [@ioquatix])
|
|
116
147
|
- `Rack::Lint` now disallows `PATH_INFO="" SCRIPT_NAME=""`. ([#2298](https://github.com/rack/rack/issues/2307), [@jeremyevans])
|
|
117
148
|
|
|
149
|
+
## [3.1.24] - 2026-11-20
|
|
150
|
+
|
|
151
|
+
### Security
|
|
152
|
+
|
|
153
|
+
- [GHSA-r243-pfwh-7rpx](https://github.com/advisories/GHSA-r243-pfwh-7rpx) Multipart boundary was extracted by substring match rather than parameter parsing, allowing parser differentials and WAF bypass.
|
|
154
|
+
- [GHSA-58mf-c3jj-277p](https://github.com/advisories/GHSA-58mf-c3jj-277p) Multipart parser searched the load path for every unknown part `charset`, allowing denial of service via CPU exhaustion.
|
|
155
|
+
- [GHSA-mhj6-xc86-54m8](https://github.com/advisories/GHSA-mhj6-xc86-54m8) `Rack::Directory` listed directories outside the root when `..` followed a symbolic link.
|
|
156
|
+
- [GHSA-frgv-948x-h96g](https://github.com/advisories/GHSA-frgv-948x-h96g) `Rack::Multipart::Parser` did not unfold a folded `Content-ID` header, preserving CRLF in the parsed parameter name.
|
|
157
|
+
- [GHSA-f7cc-57h7-qrcg](https://github.com/advisories/GHSA-f7cc-57h7-qrcg) `Rack::QueryParser` separator pattern allocated about 48 bytes per space after `&`, and nested parameter name splitting about 48 bytes per bracket, allowing denial of service via memory amplification. `DEFAULT_SEP` and the `COMMON_SEP` entries for `&` and `;` are now Strings rather than Regexps.
|
|
158
|
+
|
|
159
|
+
### Changed
|
|
160
|
+
|
|
161
|
+
- The multipart `Content-Type` header is now parsed according to RFC 9110. An unquoted `boundary` containing characters outside the token grammar (such as `=`, `/`, `:`, `?`, parentheses, or spaces), or parameters not separated by `;`, now raise `Rack::Multipart::Error` instead of being accepted. Quoted boundaries are unaffected. ([@jeremyevans](https://github.com/jeremyevans), [@tenderlove](https://github.com/tenderlove))
|
|
162
|
+
|
|
163
|
+
### Fixed
|
|
164
|
+
|
|
165
|
+
- `Rack::Multipart` no longer raises `TypeError` for a part with `charset=internal` when no default internal encoding is set; the part is treated as binary.
|
|
166
|
+
|
|
167
|
+
## [3.1.23] - 2026-10-30
|
|
168
|
+
|
|
169
|
+
### Security
|
|
170
|
+
|
|
171
|
+
- [GHSA-5v64-555j-wjxm](https://github.com/advisories/GHSA-5v64-555j-wjxm) Multipart parser retains parsed data in its scan buffer, allowing denial of service via memory exhaustion.
|
|
172
|
+
- [GHSA-wvg4-6p58-3gh3](https://github.com/advisories/GHSA-wvg4-6p58-3gh3) `Rack::Static` header rules were matched against an unnormalized path, allowing dot segments to bypass them.
|
|
173
|
+
- [GHSA-2j8w-xcrc-x985](https://github.com/advisories/GHSA-2j8w-xcrc-x985) `Rack::Request#host_with_port`, `#base_url`, and `#url` returned the raw authority when it was invalid; `host_with_port` now returns `nil` in that case.
|
|
174
|
+
- [GHSA-p8x9-v4hv-2w4g](https://github.com/advisories/GHSA-p8x9-v4hv-2w4g) Multipart requests with more than one `boundary` parameter were accepted when the first value was empty or began with a quote, semicolon, or comma, bypassing the guard added for CVE-2026-26961.
|
|
175
|
+
|
|
118
176
|
## [3.1.22] - 2026-08-13
|
|
119
177
|
|
|
120
178
|
### Security
|
|
@@ -539,6 +597,31 @@ This release introduces major improvements to Rack, including enhanced support f
|
|
|
539
597
|
- Fix multipart filename generation for filenames that contain spaces. Encode spaces as "%20" instead of "+" which will be decoded properly by the multipart parser. ([#1736](https://github.com/rack/rack/pull/1645), [@muirdm](https://github.com/muirdm))
|
|
540
598
|
- `Rack::Request#scheme` returns `ws` or `wss` when one of the `X-Forwarded-Scheme` / `X-Forwarded-Proto` headers is set to `ws` or `wss`, respectively. ([#1730](https://github.com/rack/rack/issues/1730), [@erwanst](https://github.com/erwanst))
|
|
541
599
|
|
|
600
|
+
## [2.2.26] - 2026-11-20
|
|
601
|
+
|
|
602
|
+
### Security
|
|
603
|
+
|
|
604
|
+
- [GHSA-r243-pfwh-7rpx](https://github.com/advisories/GHSA-r243-pfwh-7rpx) Multipart boundary was extracted by substring match rather than parameter parsing, allowing parser differentials and WAF bypass.
|
|
605
|
+
- [GHSA-mhj6-xc86-54m8](https://github.com/advisories/GHSA-mhj6-xc86-54m8) `Rack::Directory` listed directories outside the root when `..` followed a symbolic link.
|
|
606
|
+
- [GHSA-frgv-948x-h96g](https://github.com/advisories/GHSA-frgv-948x-h96g) `Rack::Multipart::Parser` accepted raw CR and LF characters inside quoted multipart header values, preserving them in parsed parameter names.
|
|
607
|
+
- [GHSA-f7cc-57h7-qrcg](https://github.com/advisories/GHSA-f7cc-57h7-qrcg) `Rack::QueryParser` separator pattern allocated about 48 bytes per space after `&`, and nested parameter name splitting about 48 bytes per bracket, allowing denial of service via memory amplification. The `COMMON_SEP` entries for `&` and `;` are now Strings rather than Regexps.
|
|
608
|
+
|
|
609
|
+
### Changed
|
|
610
|
+
|
|
611
|
+
- The multipart `Content-Type` header is now parsed according to RFC 9110. An unquoted `boundary` containing characters outside the token grammar (such as `=`, `/`, `:`, `?`, parentheses, or spaces), or parameters not separated by `;`, now raise `EOFError` instead of being accepted. Quoted boundaries are unaffected. ([@jeremyevans](https://github.com/jeremyevans), [@tenderlove](https://github.com/tenderlove))
|
|
612
|
+
|
|
613
|
+
## [2.2.25] - 2026-10-30
|
|
614
|
+
|
|
615
|
+
### Security
|
|
616
|
+
|
|
617
|
+
- [GHSA-5v64-555j-wjxm](https://github.com/advisories/GHSA-5v64-555j-wjxm) Multipart parser retains parsed data in its scan buffer, allowing denial of service via memory exhaustion.
|
|
618
|
+
- [GHSA-wvg4-6p58-3gh3](https://github.com/advisories/GHSA-wvg4-6p58-3gh3) `Rack::Static` header rules were matched against an unnormalized path, allowing dot segments to bypass them.
|
|
619
|
+
- [GHSA-p8x9-v4hv-2w4g](https://github.com/advisories/GHSA-p8x9-v4hv-2w4g) Multipart requests with more than one `boundary` parameter were accepted when the first value was empty or began with a quote, semicolon, or comma, bypassing the guard added for CVE-2026-26961.
|
|
620
|
+
|
|
621
|
+
### Fixed
|
|
622
|
+
|
|
623
|
+
- Multipart parser: scan boundary lines with a literal newline search instead of a backtracking regexp, which allocated tens of megabytes per scan for long lines and made the scan buffer fix above ineffective on this series.
|
|
624
|
+
|
|
542
625
|
## [2.2.24] - 2026-08-13
|
|
543
626
|
|
|
544
627
|
### Security
|
data/lib/rack/directory.rb
CHANGED
|
@@ -101,6 +101,7 @@ table { width:100%%; }
|
|
|
101
101
|
if client_error_response = check_bad_request(path_info) || check_forbidden(path_info)
|
|
102
102
|
client_error_response
|
|
103
103
|
else
|
|
104
|
+
path_info = Utils.clean_path_info(path_info)
|
|
104
105
|
path = ::File.join(@root, path_info)
|
|
105
106
|
list_path(env, path, path_info, script_name)
|
|
106
107
|
end
|
|
@@ -137,7 +138,7 @@ table { width:100%%; }
|
|
|
137
138
|
|
|
138
139
|
# Globbing not safe as path could contain glob metacharacters
|
|
139
140
|
body = DirectoryBody.new(@root, path, ->(basename) do
|
|
140
|
-
stat = stat(::File.join(path, basename))
|
|
141
|
+
stat = stat(basename == '..' ? ::File.dirname(path) : ::File.join(path, basename))
|
|
141
142
|
next unless stat
|
|
142
143
|
|
|
143
144
|
url = ::File.join(*url_head + [Utils.escape_path(basename)])
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'set'
|
|
3
4
|
require 'strscan'
|
|
4
5
|
|
|
5
6
|
require_relative '../utils'
|
|
@@ -119,19 +120,78 @@ module Rack
|
|
|
119
120
|
MultipartInfo = Struct.new :params, :tmp_files
|
|
120
121
|
EMPTY = MultipartInfo.new(nil, [])
|
|
121
122
|
|
|
123
|
+
# Parse the boundary parameter from a multipart content type, following
|
|
124
|
+
# the media type grammar in RFC 9110 Section 8.3.1:
|
|
125
|
+
#
|
|
126
|
+
# media-type = type "/" subtype parameters
|
|
127
|
+
# parameters = *( OWS ";" OWS [ parameter ] )
|
|
128
|
+
# parameter = parameter-name "=" parameter-value
|
|
129
|
+
# parameter-value = ( token / quoted-string )
|
|
130
|
+
#
|
|
131
|
+
# Returns nil if the content type is not multipart or has no boundary
|
|
132
|
+
# parameter. Raises Error if the parameters are malformed, the boundary
|
|
133
|
+
# is empty, or there is more than one boundary parameter.
|
|
122
134
|
def self.parse_boundary(content_type)
|
|
123
|
-
return unless content_type
|
|
124
|
-
data = content_type.match(MULTIPART)
|
|
125
|
-
return unless data
|
|
135
|
+
return unless content_type && content_type.match?(/\Amultipart\//ni)
|
|
126
136
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
137
|
+
scanner = StringScanner.new(content_type.b)
|
|
138
|
+
return unless scanner.skip(/multipart\/[!#$%&'*+\-.^_`|~0-9A-Za-z]+/ni)
|
|
139
|
+
|
|
140
|
+
boundary = nil
|
|
141
|
+
boundary_seen = false
|
|
142
|
+
ows = /[ \t]*/n
|
|
143
|
+
# From RFC 9110 Section 5.6.2
|
|
144
|
+
token = /[!#$%&'*+\-.^_`|~0-9A-Za-z]+/n
|
|
145
|
+
|
|
146
|
+
loop do
|
|
147
|
+
scanner.skip(ows)
|
|
148
|
+
break if scanner.eos?
|
|
149
|
+
|
|
150
|
+
unless scanner.skip(/;/n)
|
|
151
|
+
raise Error, "invalid parameters in multipart content type"
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
scanner.skip(ows)
|
|
155
|
+
# Empty parameter, such as in "a=b;;c=d" or a trailing ";".
|
|
156
|
+
next unless name = scanner.scan(token)
|
|
157
|
+
is_boundary = name.casecmp?("boundary")
|
|
158
|
+
# RFC 2231 forms such as boundary*, boundary*0, or boundary*0*. Rack
|
|
159
|
+
# does not use them, but some parsers (for example Go's
|
|
160
|
+
# mime.ParseMediaType) prefer them over a plain boundary parameter,
|
|
161
|
+
# so treat them as boundary parameters when checking for duplicates.
|
|
162
|
+
is_rfc2231_boundary = !is_boundary && name.match?(/\Aboundary\*/ni)
|
|
163
|
+
|
|
164
|
+
unless scanner.skip(/=/n)
|
|
165
|
+
if is_boundary && scanner.match?(/\s+=/n)
|
|
166
|
+
raise Error, "whitespace between boundary parameter name and equal sign"
|
|
167
|
+
end
|
|
168
|
+
raise Error, "invalid parameter in multipart content type"
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
if scanner.scan(/"((?:[\t \x21\x23-\x5B\x5D-\x7E\x80-\xFF]|\\[\t \x21-\x7E\x80-\xFF])*)"/n)
|
|
172
|
+
value = scanner[1]
|
|
173
|
+
value.gsub!(/\\(.)/mn, '\1')
|
|
174
|
+
elsif !(value = scanner.scan(token))
|
|
175
|
+
raise Error, "invalid parameter value in multipart content type"
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
next unless is_boundary || is_rfc2231_boundary
|
|
179
|
+
|
|
180
|
+
if boundary_seen
|
|
181
|
+
raise BoundaryTooLongError, "multiple boundary parameters found in multipart content type"
|
|
182
|
+
end
|
|
183
|
+
boundary_seen = true
|
|
184
|
+
|
|
185
|
+
next unless is_boundary
|
|
186
|
+
|
|
187
|
+
if value.empty?
|
|
188
|
+
raise Error, "empty boundary in multipart content type"
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
boundary = value
|
|
132
192
|
end
|
|
133
193
|
|
|
134
|
-
|
|
194
|
+
boundary
|
|
135
195
|
end
|
|
136
196
|
|
|
137
197
|
def self.parse(io, content_length, content_type, tmpfile, bufsize, qp)
|
|
@@ -464,6 +524,7 @@ module Rack
|
|
|
464
524
|
end
|
|
465
525
|
else
|
|
466
526
|
name = head[MULTIPART_CONTENT_ID, 1]
|
|
527
|
+
name.gsub!(OBS_UNFOLD, '\1') if name
|
|
467
528
|
end
|
|
468
529
|
|
|
469
530
|
if filename_star
|
|
@@ -494,6 +555,7 @@ module Rack
|
|
|
494
555
|
# buffering. Note that the actual limit is the higher of 64KB and the buffer size (1MB by default)
|
|
495
556
|
raise Error, "multipart mime part header too large" if @sbuf.rest.bytesize > MIME_HEADER_BYTESIZE_LIMIT
|
|
496
557
|
|
|
558
|
+
@sbuf.string = @sbuf.rest
|
|
497
559
|
return :want_read
|
|
498
560
|
end
|
|
499
561
|
end
|
|
@@ -514,8 +576,8 @@ module Rack
|
|
|
514
576
|
update_retained_size(body.bytesize) if @body_retained
|
|
515
577
|
@collector.on_mime_body @mime_index, body
|
|
516
578
|
@sbuf.pos += delta
|
|
517
|
-
@sbuf.string = @sbuf.rest
|
|
518
579
|
end
|
|
580
|
+
@sbuf.string = @sbuf.rest
|
|
519
581
|
:want_read
|
|
520
582
|
end
|
|
521
583
|
end
|
|
@@ -583,13 +645,27 @@ module Rack
|
|
|
583
645
|
body.force_encoding(encoding)
|
|
584
646
|
end
|
|
585
647
|
|
|
648
|
+
ENCODING_NAMES = Set.new(Encoding.name_list.map(&:downcase)).freeze
|
|
649
|
+
private_constant :ENCODING_NAMES
|
|
650
|
+
|
|
586
651
|
# Return the related Encoding object. However, because
|
|
587
652
|
# enc is submitted by the user, it may be invalid, so
|
|
588
653
|
# use a binary encoding in that case.
|
|
589
654
|
def find_encoding(enc)
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
655
|
+
if respect_requested_encoding?(enc)
|
|
656
|
+
begin
|
|
657
|
+
Encoding.find(enc)
|
|
658
|
+
rescue ArgumentError
|
|
659
|
+
nil
|
|
660
|
+
end
|
|
661
|
+
end || Encoding::BINARY
|
|
662
|
+
end
|
|
663
|
+
|
|
664
|
+
# Whether to respect the given encoding (given as a string). If a
|
|
665
|
+
# requested encoding is not respected, binary encoding is used.
|
|
666
|
+
# The string may be nil or in any encoding, so compare it as bytes.
|
|
667
|
+
def respect_requested_encoding?(encoding_string)
|
|
668
|
+
ENCODING_NAMES.include?(encoding_string.to_s.b.downcase(:ascii))
|
|
593
669
|
end
|
|
594
670
|
|
|
595
671
|
REENCODE_DUMMY_ENCODINGS = {
|
data/lib/rack/query_parser.rb
CHANGED
|
@@ -5,8 +5,8 @@ require 'uri'
|
|
|
5
5
|
|
|
6
6
|
module Rack
|
|
7
7
|
class QueryParser
|
|
8
|
-
DEFAULT_SEP =
|
|
9
|
-
COMMON_SEP = { ";" =>
|
|
8
|
+
DEFAULT_SEP = "&"
|
|
9
|
+
COMMON_SEP = { ";" => ";", ";," => /[;,]/n, "&" => "&" }
|
|
10
10
|
|
|
11
11
|
# ParameterTypeError is the error that is raised when incoming structural
|
|
12
12
|
# parameters (parsed by parse_nested_query) contain conflicting types.
|
|
@@ -210,10 +210,17 @@ module Rack
|
|
|
210
210
|
def params_hash_has_key?(hash, key)
|
|
211
211
|
return false if /\[\]/.match?(key)
|
|
212
212
|
|
|
213
|
-
key.split(/[\[\]]+/)
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
# Equivalent to walking key.split(/[\[\]]+/), but a quantified regexp
|
|
214
|
+
# allocates backtracking state for every bracket matched, so find the
|
|
215
|
+
# segments with single character searches instead, which do not
|
|
216
|
+
# backtrack.
|
|
217
|
+
pos = 0
|
|
218
|
+
while (start = key.index(/[^\[\]]/, pos))
|
|
219
|
+
stop = key.index(/[\[\]]/, start) || key.length
|
|
220
|
+
part = key[start, stop - start]
|
|
221
|
+
return false unless params_hash_type?(hash) && hash.key?(part)
|
|
222
|
+
hash = hash[part]
|
|
223
|
+
pos = stop
|
|
217
224
|
end
|
|
218
225
|
|
|
219
226
|
true
|
|
@@ -226,7 +233,14 @@ module Rack
|
|
|
226
233
|
raise QueryLimitError, "total query size exceeds limit (#{@bytesize_limit})"
|
|
227
234
|
end
|
|
228
235
|
|
|
229
|
-
pairs = qs.split(separator ? (COMMON_SEP[separator] || /[#{separator}]
|
|
236
|
+
pairs = qs.split(separator ? (COMMON_SEP[separator] || /[#{separator}]/n) : DEFAULT_SEP, @params_limit + 1)
|
|
237
|
+
|
|
238
|
+
# Remove spaces following the separator. A quantified regexp such as
|
|
239
|
+
# /& */ allocates backtracking state for every space matched, so find
|
|
240
|
+
# the first non-space character instead, which does not backtrack.
|
|
241
|
+
pairs.each do |pair|
|
|
242
|
+
pair.slice!(0, pair.index(/[^ ]/) || pair.length) if pair.getbyte(0) == 32
|
|
243
|
+
end
|
|
230
244
|
|
|
231
245
|
if pairs.size > @params_limit
|
|
232
246
|
param_count = pairs.size + pairs.last.count(separator || "&")
|
data/lib/rack/request.rb
CHANGED
|
@@ -325,8 +325,10 @@ module Rack
|
|
|
325
325
|
end
|
|
326
326
|
|
|
327
327
|
def host_with_port(authority = self.authority)
|
|
328
|
-
|
|
328
|
+
parts = split_authority(authority)
|
|
329
|
+
return nil if parts.empty?
|
|
329
330
|
|
|
331
|
+
host, _, port = parts
|
|
330
332
|
if port == DEFAULT_PORTS[self.scheme]
|
|
331
333
|
host
|
|
332
334
|
else
|
|
@@ -592,7 +594,8 @@ module Rack
|
|
|
592
594
|
end
|
|
593
595
|
|
|
594
596
|
def base_url
|
|
595
|
-
|
|
597
|
+
hostport = host_with_port || host_with_port(server_authority)
|
|
598
|
+
"#{scheme}://#{hostport}"
|
|
596
599
|
end
|
|
597
600
|
|
|
598
601
|
# Tries to return a remake of the original request URL as a string.
|
data/lib/rack/static.rb
CHANGED
|
@@ -168,7 +168,7 @@ module Rack
|
|
|
168
168
|
|
|
169
169
|
# Convert HTTP header rules to HTTP headers
|
|
170
170
|
def applicable_rules(path)
|
|
171
|
-
path = ::Rack::Utils.unescape_path(path)
|
|
171
|
+
path = ::Rack::Utils.clean_path_info(::Rack::Utils.unescape_path(path))
|
|
172
172
|
|
|
173
173
|
@header_rules.find_all do |rule, new_headers|
|
|
174
174
|
case rule
|
data/lib/rack/version.rb
CHANGED