summary refs log tree commit
diff options
context:
space:
mode:
authorDaniel Rodríguez Troitiño <drodrigueztroitino@yahoo.es>2009-10-08 08:48:34 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2009-10-18 20:42:58 +0200
commit354073d9a2071fa58e18d471bb6bd70dd171face (patch)
treec02711ecfc262e9f42138a9f00b0685ba4bbb9ea
parent38f205e975d3e540cc81a71a639f4bebc3c2a293 (diff)
downloadrack-354073d9a2071fa58e18d471bb6bd70dd171face.tar.gz
Test multipart upload with a semicolon in the name.
Test a multipart upload in which the specified
filename includes a semicolon. Should be parsed
with the included filename, but Rack stops at the
filename.

Signed-off-by: Christian Neukirchen <chneukirchen@gmail.com>
-rw-r--r--test/multipart/semicolon6
-rw-r--r--test/spec_rack_utils.rb12
2 files changed, 18 insertions, 0 deletions
diff --git a/test/multipart/semicolon b/test/multipart/semicolon
new file mode 100644
index 00000000..00fd68ab
--- /dev/null
+++ b/test/multipart/semicolon
@@ -0,0 +1,6 @@
+--AaB03x
+Content-Disposition: form-data; name="files"; filename="fi;le1.txt"
+Content-Type: text/plain
+
+contents
+--AaB03x-- \ No newline at end of file
diff --git a/test/spec_rack_utils.rb b/test/spec_rack_utils.rb
index c3974299..52333773 100644
--- a/test/spec_rack_utils.rb
+++ b/test/spec_rack_utils.rb
@@ -383,6 +383,18 @@ context "Rack::Utils::Multipart" do
     params["files"][:tempfile].read.should.equal ""
   end
 
+  specify "should parse multipart upload with filename with semicolons" do
+    env = Rack::MockRequest.env_for("/", multipart_fixture(:semicolon))
+    params = Rack::Utils::Multipart.parse_multipart(env)
+    params["files"][:type].should.equal "text/plain"
+    params["files"][:filename].should.equal "fi;le1.txt"
+    params["files"][:head].should.equal "Content-Disposition: form-data; " +
+      "name=\"files\"; filename=\"fi;le1.txt\"\r\n" +
+      "Content-Type: text/plain\r\n"
+    params["files"][:name].should.equal "files"
+    params["files"][:tempfile].read.should.equal "contents"
+  end
+
   specify "should not include file params if no file was selected" do
     env = Rack::MockRequest.env_for("/", multipart_fixture(:none))
     params = Rack::Utils::Multipart.parse_multipart(env)