From 202419ea6335d74db0d53ac4093f43c5261df559 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 17 May 2011 16:46:54 -0400 Subject: [PATCH] Test that parsing a multipart/mixed upload no longer blows up --- test/multipart/mixed_files | 21 +++++++++++++++++++++ test/spec_multipart.rb | 10 +++++++++- 2 files changed, 30 insertions(+), 1 deletions(-) create mode 100644 test/multipart/mixed_files 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_multipart.rb b/test/spec_multipart.rb index 26341fb..fcd825c 100644 --- a/test/spec_multipart.rb +++ b/test/spec_multipart.rb @@ -110,6 +110,14 @@ describe Rack::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::Multipart.parse_multipart(env) @@ -276,4 +284,4 @@ describe Rack::Multipart do message.should.equal "value must be a Hash" end -end \ No newline at end of file +end -- 1.7.4.4