rack 3.1.21 → 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 +59 -79
- 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 +3 -6
- 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 +37 -94
- data/lib/rack/multipart/uploaded_file.rb +42 -5
- data/lib/rack/query_parser.rb +41 -26
- data/lib/rack/request.rb +48 -60
- 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
|
|
@@ -119,9 +118,7 @@ table { width:100%%; }
|
|
|
119
118
|
# Rack response to use for requests with paths outside the root, or nil if path is inside the root.
|
|
120
119
|
def check_forbidden(path_info)
|
|
121
120
|
return unless path_info.include? ".."
|
|
122
|
-
|
|
123
|
-
expanded_path = ::File.expand_path(::File.join(@root, path_info))
|
|
124
|
-
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)
|
|
125
122
|
|
|
126
123
|
body = "Forbidden\n"
|
|
127
124
|
[403, { CONTENT_TYPE => "text/plain",
|
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
|