Skip to content

Commit

Permalink
Correct the regex for finding the part name by Content-Id header. Fix…
Browse files Browse the repository at this point in the history
…es issue rack#98 at rack/rack

Signed-off-by: raggi <jftucker@gmail.com>
  • Loading branch information
Dave Myron authored and raggi committed Jan 1, 2011
1 parent 859ab9f commit 62c4969
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rack/utils.rb
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions test/spec_request.rb
Expand Up @@ -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
Expand Down

0 comments on commit 62c4969

Please sign in to comment.