diff options
author | Dave Myron <dave.myron@contentfree.com> | 2010-12-23 13:07:13 -0800 |
---|---|---|
committer | raggi <jftucker@gmail.com> | 2010-12-31 20:21:51 -0500 |
commit | 62c49691b0f23b798843db07228af008c919e485 (patch) | |
tree | ee23617aa3f877bd40701de64f0a7f7f6aafa0d7 | |
parent | 859ab9f1455d42a7e5879024ea9505ac810b1726 (diff) | |
download | rack-62c49691b0f23b798843db07228af008c919e485.tar.gz |
Correct the regex for finding the part name by Content-Id header. Fixes issue #98 at rack/rack
Signed-off-by: raggi <jftucker@gmail.com>
-rw-r--r-- | lib/rack/utils.rb | 2 | ||||
-rw-r--r-- | test/spec_request.rb | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/rack/utils.rb b/lib/rack/utils.rb index 725646ea..33ea2aad 100644 --- a/lib/rack/utils.rb +++ b/lib/rack/utils.rb @@ -507,7 +507,7 @@ module Rack 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 diff --git a/test/spec_request.rb b/test/spec_request.rb index c985d5a6..f3339669 100644 --- a/test/spec_request.rb +++ b/test/spec_request.rb @@ -550,6 +550,24 @@ EOF 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 |