rack 3.1.24 → 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.
Potentially problematic release.
This version of rack might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +57 -134
- data/README.md +41 -28
- 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/directory.rb +4 -8
- data/lib/rack/files.rb +1 -1
- 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 +42 -181
- data/lib/rack/multipart/uploaded_file.rb +42 -5
- data/lib/rack/query_parser.rb +43 -48
- data/lib/rack/request.rb +50 -65
- data/lib/rack/rewindable_input.rb +4 -1
- data/lib/rack/sendfile.rb +21 -51
- data/lib/rack/show_exceptions.rb +4 -2
- data/lib/rack/show_status.rb +0 -2
- data/lib/rack/static.rb +3 -7
- data/lib/rack/utils.rb +28 -129
- data/lib/rack/version.rb +4 -8
- data/lib/rack.rb +0 -1
- metadata +3 -3
- data/lib/rack/logger.rb +0 -23
data/lib/rack/directory.rb
CHANGED
|
@@ -17,7 +17,7 @@ module Rack
|
|
|
17
17
|
# If +app+ is not specified, a Rack::Files of the same +root+ will be used.
|
|
18
18
|
|
|
19
19
|
class Directory
|
|
20
|
-
DIR_FILE = "<tr><td class='name'><a href='
|
|
20
|
+
DIR_FILE = "<tr><td class='name'><a href='%s'>%s</a></td><td class='size'>%s</td><td class='type'>%s</td><td class='mtime'>%s</td></tr>\n"
|
|
21
21
|
DIR_PAGE_HEADER = <<-PAGE
|
|
22
22
|
<html><head>
|
|
23
23
|
<title>%s</title>
|
|
@@ -51,7 +51,7 @@ table { width:100%%; }
|
|
|
51
51
|
class DirectoryBody < Struct.new(:root, :path, :files)
|
|
52
52
|
# Yield strings for each part of the directory entry
|
|
53
53
|
def each
|
|
54
|
-
show_path = Utils.escape_html(path.sub(
|
|
54
|
+
show_path = Utils.escape_html(path.sub(/^#{root}/, ''))
|
|
55
55
|
yield(DIR_PAGE_HEADER % [ show_path, show_path ])
|
|
56
56
|
|
|
57
57
|
unless path.chomp('/') == root
|
|
@@ -82,7 +82,6 @@ table { width:100%%; }
|
|
|
82
82
|
# Set the root directory and application for serving files.
|
|
83
83
|
def initialize(root, app = nil)
|
|
84
84
|
@root = ::File.expand_path(root)
|
|
85
|
-
@root_with_separator = @root.end_with?(::File::SEPARATOR) ? @root : "#{@root}#{::File::SEPARATOR}"
|
|
86
85
|
@app = app || Files.new(@root)
|
|
87
86
|
@head = Head.new(method(:get))
|
|
88
87
|
end
|
|
@@ -101,7 +100,6 @@ table { width:100%%; }
|
|
|
101
100
|
if client_error_response = check_bad_request(path_info) || check_forbidden(path_info)
|
|
102
101
|
client_error_response
|
|
103
102
|
else
|
|
104
|
-
path_info = Utils.clean_path_info(path_info)
|
|
105
103
|
path = ::File.join(@root, path_info)
|
|
106
104
|
list_path(env, path, path_info, script_name)
|
|
107
105
|
end
|
|
@@ -120,9 +118,7 @@ table { width:100%%; }
|
|
|
120
118
|
# Rack response to use for requests with paths outside the root, or nil if path is inside the root.
|
|
121
119
|
def check_forbidden(path_info)
|
|
122
120
|
return unless path_info.include? ".."
|
|
123
|
-
|
|
124
|
-
expanded_path = ::File.expand_path(::File.join(@root, path_info))
|
|
125
|
-
return if expanded_path == @root || expanded_path.start_with?(@root_with_separator)
|
|
121
|
+
return if ::File.expand_path(::File.join(@root, path_info)).start_with?(@root)
|
|
126
122
|
|
|
127
123
|
body = "Forbidden\n"
|
|
128
124
|
[403, { CONTENT_TYPE => "text/plain",
|
|
@@ -138,7 +134,7 @@ table { width:100%%; }
|
|
|
138
134
|
|
|
139
135
|
# Globbing not safe as path could contain glob metacharacters
|
|
140
136
|
body = DirectoryBody.new(@root, path, ->(basename) do
|
|
141
|
-
stat = stat(
|
|
137
|
+
stat = stat(::File.join(path, basename))
|
|
142
138
|
next unless stat
|
|
143
139
|
|
|
144
140
|
url = ::File.join(*url_head + [Utils.escape_path(basename)])
|
data/lib/rack/files.rb
CHANGED
data/lib/rack/head.rb
CHANGED
|
@@ -15,9 +15,8 @@ module Rack
|
|
|
15
15
|
_, _, body = response = @app.call(env)
|
|
16
16
|
|
|
17
17
|
if env[REQUEST_METHOD] == HEAD
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
end
|
|
18
|
+
body.close if body.respond_to?(:close)
|
|
19
|
+
response[2] = []
|
|
21
20
|
end
|
|
22
21
|
|
|
23
22
|
response
|