Skip to content

Commit

Permalink
Test that parsing a multipart/mixed upload no longer blows up
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed May 17, 2011
1 parent c16729d commit e8a155a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
21 changes: 21 additions & 0 deletions 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--
10 changes: 9 additions & 1 deletion test/spec_multipart.rb
Expand Up @@ -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)
Expand Down Expand Up @@ -276,4 +284,4 @@ def multipart_file(name)
message.should.equal "value must be a Hash"
end

end
end
2 changes: 1 addition & 1 deletion test/spec_utils.rb
Expand Up @@ -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
Copy link
Contributor

@josh josh commented on e8a155a May 19, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@tenderlove
Copy link
Member

@tenderlove tenderlove commented on e8a155a May 19, 2011 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeremy
Copy link
Member Author

@jeremy jeremy commented on e8a155a May 20, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josh line endings - how do they work?

@josh
Copy link
Contributor

@josh josh commented on e8a155a May 20, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raggi got it d24f775

Please sign in to comment.