Permalink
Browse files

Correct the regex for finding the part name by Content-Id header. Fix…

…es issue #98 at rack/rack

Signed-off-by: raggi <jftucker@gmail.com>
  • Loading branch information...
1 parent 859ab9f commit 62c49691b0f23b798843db07228af008c919e485 Dave Myron committed with raggi Dec 23, 2010
Showing with 19 additions and 1 deletion.
  1. +1 −1 lib/rack/utils.rb
  2. +18 −0 test/spec_request.rb
View
@@ -507,7 +507,7 @@ def method_missing(method_name, *args, &block) #:nodoc:
BROKEN_UNQUOTED = /^#{CONDISP}.*;\sfilename=(#{TOKEN})/i
MULTIPART_CONTENT_TYPE = /Content-Type: (.*)#{EOL}/ni
MULTIPART_CONTENT_DISPOSITION = /Content-Disposition:.*\s+name="?([^\";]*)"?/ni
- MULTIPART_CONTENT_ID = /Content-ID:([^#{EOL}]*)/ni
+ MULTIPART_CONTENT_ID = /Content-ID:\s*([^#{EOL}]*)/ni
def self.parse_multipart(env)
unless env['CONTENT_TYPE'] =~ MULTIPART
View
@@ -550,6 +550,24 @@
lambda { req.POST }.should.raise(EOFError)
end
+
+ should "correctly parse the part name from Content-Id header" do
+ input = <<EOF
+--AaB03x\r
+Content-Type: text/xml; charset=utf-8\r
+Content-Id: <soap-start>\r
+Content-Transfer-Encoding: 7bit\r
+\r
+foo\r
+--AaB03x--\r
+EOF
+ req = Rack::Request.new Rack::MockRequest.env_for("/",
+ "CONTENT_TYPE" => "multipart/related, boundary=AaB03x",
+ "CONTENT_LENGTH" => input.size,
+ :input => input)
+
+ req.params.keys.should.equal ["<soap-start>"]
+ end
should "not try to interpret binary as utf8" do
if /regexp/.respond_to?(:kcode) # < 1.9

0 comments on commit 62c4969

Please sign in to comment.