summary refs log tree commit
diff options
context:
space:
mode:
authorJames Tucker <jftucker@gmail.com>2014-07-18 15:41:42 -0700
committerJames Tucker <jftucker@gmail.com>2014-07-18 15:41:42 -0700
commit837b0e6ccf737b90c20977c8d6ac8bb5fbac2e3e (patch)
tree3885a53af4e4453b4ed36844d892743d3a484cd8
parent2754224570978756fdbaf3f1842a229d3ab95913 (diff)
downloadrack-837b0e6ccf737b90c20977c8d6ac8bb5fbac2e3e.tar.gz
correct weird case regression from #714
-rw-r--r--lib/rack/request.rb11
-rw-r--r--test/spec_request.rb3
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/rack/request.rb b/lib/rack/request.rb
index ac94026c..52ea652c 100644
--- a/lib/rack/request.rb
+++ b/lib/rack/request.rb
@@ -52,7 +52,7 @@ module Rack
       return {} if content_type.nil?
       Hash[*content_type.split(/\s*[;,]\s*/)[1..-1].
         collect { |s| s.split('=', 2) }.
-        map { |k,v| [k.downcase, v.gsub(/\A"|"\z/, "")] }.flatten]
+        map { |k,v| [k.downcase, strip_doublequotes(v)] }.flatten]
     end
 
     # The character set of the request body if a "charset" media type
@@ -383,5 +383,14 @@ module Rack
           [attribute, quality]
         end
       end
+
+  private
+    def strip_doublequotes(s)
+      if s[0] == ?" && s[-1] == ?"
+        s[1..-2]
+      else
+        s
+      end
+    end
   end
 end
diff --git a/test/spec_request.rb b/test/spec_request.rb
index b2257c7c..8a2b4760 100644
--- a/test/spec_request.rb
+++ b/test/spec_request.rb
@@ -623,7 +623,7 @@ describe Rack::Request do
   should "handle multiple media type parameters" do
     req = Rack::Request.new \
       Rack::MockRequest.env_for("/",
-        "CONTENT_TYPE" => 'text/plain; foo=BAR,baz=bizzle dizzle;BLING=bam;blong="boo";zump="zoo\"o"')
+        "CONTENT_TYPE" => 'text/plain; foo=BAR,baz=bizzle dizzle;BLING=bam;blong="boo";zump="zoo\"o";weird=lol"')
       req.should.not.be.form_data
       req.media_type_params.should.include 'foo'
       req.media_type_params['foo'].should.equal 'BAR'
@@ -634,6 +634,7 @@ describe Rack::Request do
       req.media_type_params['bling'].should.equal 'bam'
       req.media_type_params['blong'].should.equal 'boo'
       req.media_type_params['zump'].should.equal 'zoo\"o'
+      req.media_type_params['weird'].should.equal 'lol"'
   end
 
   should "parse with junk before boundry" do