summary refs log tree commit
path: root/test/spec_request.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2015-06-19 07:00:32 +0930
committerMatthew Draper <matthew@trebex.net>2015-06-19 07:17:59 +0930
commit62d54eada90158033ba47f804d06adfc75940dc5 (patch)
treecd7a607e36c6a883e3087c69cf69f775e4740363 /test/spec_request.rb
parentcb9a68493b5a17a35c31b2c8cbacd81d5b0e4fae (diff)
downloadrack-62d54eada90158033ba47f804d06adfc75940dc5.tar.gz
Fix GET semicolons without breaking API compatibility
Well.. without breaking compatibility in a way that affects Rails.
Diffstat (limited to 'test/spec_request.rb')
-rw-r--r--test/spec_request.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/test/spec_request.rb b/test/spec_request.rb
index 6f379a0b..a44e0a71 100644
--- a/test/spec_request.rb
+++ b/test/spec_request.rb
@@ -134,12 +134,23 @@ describe Rack::Request do
     req.params.should.equal "foo" => "bar", "quux" => "bla"
   end
 
-  should "not truncate query strings containing semi-colons #543" do
-    req = Rack::Request.new(Rack::MockRequest.env_for("/?foo=bar&quux=b;la"))
-    req.query_string.should.equal "foo=bar&quux=b;la"
-    req.GET.should.equal "foo" => "bar", "quux" => "b;la"
+  should "not truncate query strings containing semi-colons #543 only in POST" do
+    mr = Rack::MockRequest.env_for("/",
+      "REQUEST_METHOD" => 'POST',
+      :input => "foo=bar&quux=b;la")
+    req = Rack::Request.new mr
+    req.query_string.should.equal ""
+    req.GET.should.be.empty
+    req.POST.should.equal "foo" => "bar", "quux" => "b;la"
+    req.params.should.equal req.GET.merge(req.POST)
+  end
+
+  should "use semi-colons as separators for query strings in GET" do
+    req = Rack::Request.new(Rack::MockRequest.env_for("/?foo=bar&quux=b;la;wun=duh"))
+    req.query_string.should.equal "foo=bar&quux=b;la;wun=duh"
+    req.GET.should.equal "foo" => "bar", "quux" => "b", "la" => nil, "wun" => "duh"
     req.POST.should.be.empty
-    req.params.should.equal "foo" => "bar", "quux" => "b;la"
+    req.params.should.equal "foo" => "bar", "quux" => "b", "la" => nil, "wun" => "duh"
   end
 
   should "limit the keys from the GET query string" do