Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow rack.input.read(integer), needed for safe multipart parsing

darcs-hash:20070228125624-4fc50-6f914e6a627ea7e74a3b6c4327d7c96c8bb93518.gz
  • Loading branch information...
commit 758f928783ea935dd082414bb783bdde8a6df68e 1 parent e2de2b0
@chneukirchen chneukirchen authored
View
8 lib/rack/handler/fastcgi.rb
@@ -16,8 +16,12 @@ def each # This is missing by default.
end
end
- def read
- super || "" # Empty string on EOF.
+ def read(*args)
+ if args.empty?
+ super || "" # Empty string on EOF.
+ else
+ super
+ end
end
end
View
15 lib/rack/lint.rb
@@ -217,11 +217,18 @@ def gets(*args)
v
end
- ## * +read+ must be called without arguments and return a string,
- ## or +nil+ on EOF.
+ ## * +read+ must be called without or with one integer argument
+ ## and return a string, or +nil+ on EOF.
def read(*args)
- assert("rack.input#read called with arguments") { args.size == 0 }
- v = @input.read
+ assert("rack.input#read called with too many arguments") {
+ args.size < 1
+ }
+ if args.size == 1
+ assert("rack.input#read called with non-integer argument") {
+ args.first.instance_of? Integer
+ }
+ end
+ v = @input.read(*args)
assert("rack.input#read didn't return a String") {
v.nil? or v.instance_of? String
}
View
4 test/spec_rack_lint.rb
@@ -234,11 +234,11 @@ def env(*args)
lambda {
Rack::Lint.new(lambda { |env|
- env["rack.input"].read(4096)
+ env["rack.input"].read("foo")
[201, {"Content-type" => "text/plain"}, ""]
}).call(env({}))
}.should.raise(Rack::Lint::LintError).
- message.should.match(/read called with arguments/)
+ message.should.match(/read called with too many arguments/)
weirdio = Object.new
class << weirdio
Please sign in to comment.
Something went wrong with that request. Please try again.