From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.239.138.72 with SMTP id o8cs75391hbo; Sun, 4 Jul 2010 15:06:59 -0700 (PDT) Return-Path: Received-SPF: pass (google.com: domain of rack-devel+bncCI7buMj8DBCBjMThBBoE7pjIOg@googlegroups.com designates 10.220.122.198 as permitted sender) client-ip=10.220.122.198; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rack-devel+bncCI7buMj8DBCBjMThBBoE7pjIOg@googlegroups.com designates 10.220.122.198 as permitted sender) smtp.mail=rack-devel+bncCI7buMj8DBCBjMThBBoE7pjIOg@googlegroups.com; dkim=pass header.i=rack-devel+bncCI7buMj8DBCBjMThBBoE7pjIOg@googlegroups.com Received: from mr.google.com ([10.220.122.198]) by 10.220.122.198 with SMTP id m6mr286313vcr.33.1278281218511 (num_hops = 1); Sun, 04 Jul 2010 15:06:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:x-beenthere:received:received:received :received:received-spf:received:mime-version:received:received:date :message-id:subject:from:to:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; bh=gsBJNWLkwqh4cDRJvEm0t2EKt+LEnro0ewmwzQyBZVI=; b=rL3qO5SWqfZDNcy22K7EmKyq8ncmQl9LH5cRbAMfQi2e/aydddJQZHZIIrNZy22XTM qYG4WjLWBuOhamWWZifZLawhKh3SBWskQGKvcnTlDTNHJ+4E7PovSYcENqh85d0ln1lC ZXnmsGkFPAKNKGrY8xaT2h7NfFQ6Yzv2GZdq4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:mime-version:date:message-id:subject:from :to:x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :sender:list-subscribe:list-unsubscribe:content-type; b=vH/MGZ7fUksQ++ua0NpEBh4h5D75yfvfDlMSLQqcmUYR9FbWYK339P98zuJln2IjEQ odBSEKSgQgL5pRdrjkPe0EKpU5Cik3FOCwC3vejHJgSyNWkzn7QZB2gtaDdRpN2lz/iT wsTntOyJbXkEX44wVgD8b2XnmtCcUul3HTujY= Received: by 10.220.122.198 with SMTP id m6mr69276vcr.33.1278281217341; Sun, 04 Jul 2010 15:06:57 -0700 (PDT) X-BeenThere: rack-devel@googlegroups.com Received: by 10.220.80.27 with SMTP id r27ls3548626vck.0.p; Sun, 04 Jul 2010 15:06:55 -0700 (PDT) Received: by 10.220.201.198 with SMTP id fb6mr418592vcb.6.1278281215541; Sun, 04 Jul 2010 15:06:55 -0700 (PDT) Received: by 10.220.201.198 with SMTP id fb6mr418590vcb.6.1278281215518; Sun, 04 Jul 2010 15:06:55 -0700 (PDT) Received: from mail-qy0-f171.google.com (mail-qy0-f171.google.com [209.85.216.171]) by gmr-mx.google.com with ESMTP id m6si537536vcs.5.2010.07.04.15.06.55; Sun, 04 Jul 2010 15:06:55 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.216.171 is neither permitted nor denied by best guess record for domain of jeremy@bitsweat.net) client-ip=209.85.216.171; Received: by qyk9 with SMTP id 9so1562714qyk.2 for ; Sun, 04 Jul 2010 15:06:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.123.227 with SMTP id q35mr937871qar.137.1278281214807; Sun, 04 Jul 2010 15:06:54 -0700 (PDT) Received: by 10.229.47.9 with HTTP; Sun, 4 Jul 2010 15:06:54 -0700 (PDT) Date: Sun, 4 Jul 2010 15:06:54 -0700 Message-ID: Subject: Fix for multipart parsing regression From: Jeremy Kemper To: rack-devel@googlegroups.com X-Original-Sender: jeremy@bitsweat.net X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 209.85.216.171 is neither permitted nor denied by best guess record for domain of jeremy@bitsweat.net) smtp.mail=jeremy@bitsweat.net Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: Sender: rack-devel@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Type: text/plain; charset=ISO-8859-1 Rack 1.2.1 raises an exception when parsing a multipart/mixed request. acffe8ef5 introduced the regression. Fix and test: http://github.com/jeremy/rack/commit/f4e4b1a >From f4e4b1ac447fd571056049ad24ba042fa46dba6c Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 27 Jun 2010 17:38:08 -0700 Subject: [PATCH] Fix multipart/mixed parsing regression introduced by acffe8ef5. [#79] --- lib/rack/utils.rb | 6 ------ test/multipart/mixed_files | 21 +++++++++++++++++++++ test/spec_utils.rb | 8 ++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 test/multipart/mixed_files diff --git a/lib/rack/utils.rb b/lib/rack/utils.rb index bc60cd1..3748392 100644 --- a/lib/rack/utils.rb +++ b/lib/rack/utils.rb @@ -571,12 +571,6 @@ module Rack data = {:filename => filename, :type => content_type, :name => name, :tempfile => body, :head => head} - elsif !filename && content_type - body.rewind - - # Generic multipart cases, not coming from a form - data = {:type => content_type, - :name => name, :tempfile => body, :head => head} else data = body end diff --git a/test/multipart/mixed_files b/test/multipart/mixed_files new file mode 100644 index 0000000..624d804 --- /dev/null +++ b/test/multipart/mixed_files @@ -0,0 +1,21 @@ +--AaB03x +Content-Disposition: form-data; name="foo" + +bar +--AaB03x +Content-Disposition: form-data; name="files" +Content-Type: multipart/mixed, boundary=BbC04y + +--BbC04y +Content-Disposition: attachment; filename="file.txt" +Content-Type: text/plain + +contents +--BbC04y +Content-Disposition: attachment; filename="flowers.jpg" +Content-Type: image/jpeg +Content-Transfer-Encoding: binary + +contents +--BbC04y-- +--AaB03x-- diff --git a/test/spec_utils.rb b/test/spec_utils.rb index 822058b..d9d073b 100644 --- a/test/spec_utils.rb +++ b/test/spec_utils.rb @@ -449,6 +449,14 @@ describe Rack::Utils::Multipart do params.keys.should.not.include "files" end + should "parse multipart/mixed" do + env = Rack::MockRequest.env_for("/", multipart_fixture(:mixed_files)) + params = Rack::Utils::Multipart.parse_multipart(env) + params["foo"].should.equal "bar" + params["files"].should.be.instance_of String + params["files"].size.should.equal 252 + end + should "parse IE multipart upload and clean up filename" do env = Rack::MockRequest.env_for("/", multipart_fixture(:ie)) params = Rack::Utils::Multipart.parse_multipart(env) -- 1.7.1