Skip to content
Browse files

Test that parsing a multipart/mixed upload no longer blows up

  • Loading branch information...
1 parent c16729d commit e8a155a7174a375b1d2ee1e015e77e2b1977c5ac @jeremy jeremy committed Jun 27, 2010
Showing with 31 additions and 2 deletions.
  1. +21 −0 test/multipart/mixed_files
  2. +9 −1 test/spec_multipart.rb
  3. +1 −1 test/spec_utils.rb
View
21 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--
View
10 test/spec_multipart.rb
@@ -110,6 +110,14 @@ def multipart_file(name)
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 @@ def multipart_file(name)
message.should.equal "value must be a Hash"
end
-end
+end
View
2 test/spec_utils.rb
@@ -427,4 +427,4 @@ def context env, app=@app; app.call(env); end
r5.status.should.equal 200
r4.body.should.equal r5.body
end
-end
+end

4 comments on commit e8a155a

@josh
josh commented on e8a155a May 19, 2011

@jeremy this fails dude, why did you trick me into pulling it!

@tenderlove
Official Rack repositories member
@jeremy
Official Rack repositories member
jeremy commented on e8a155a May 20, 2011

@josh line endings - how do they work?

@josh
josh commented on e8a155a May 20, 2011

@raggi got it d24f775

Please sign in to comment.
Something went wrong with that request. Please try again.