[Muffin Cake] parse_query / normalize_params issues

8 views
Skip to first unread message

Christian Neukirchen

unread,
Mar 18, 2010, 6:44:32 PM3/18/10
to Rack Development

Date: Thu, 18 Mar 2010 15:32:19 -0700 (PDT)
From: Muffin Cake <cakemu...@yahoo.com>
Subject: parse_query / normalize_params issues
To: chneuk...@gmail.com

Hey,

Rack is great.

I found a small issue, that took me quite a while to uncover though:

In parse_query and normalize_params there is a special case when a param starts and ends with " or '. And it removes them. What is the reasoning behind this?

app?q="a" --> {"q"=>"a"} instead of {"q"=>"\"a\""}

eg. compare to google, searching for "funny quotes"

There is even a test case for this behaviour, which I found oddly surprising.

Thanks!

Simon Chiang

unread,
Mar 19, 2010, 5:13:02 PM3/19/10
to Rack Development
See also http://groups.google.com/group/rack-devel/browse_thread/thread/f81f79e633b9e086
-- same question.

On Mar 18, 4:44 pm, Christian Neukirchen <chneukirc...@gmail.com>
wrote:


> Date: Thu, 18 Mar 2010 15:32:19 -0700 (PDT)

> From: Muffin Cake <cakemuffi...@yahoo.com>


> Subject: parse_query / normalize_params issues

> To: chneukirc...@gmail.com

Ryan Tomayko

unread,
Apr 29, 2010, 6:08:26 PM4/29/10
to rack-...@googlegroups.com
I've committed a failing test from Job Bardin for this. This is
certainly a bug, yes? I can't imagine a reason Rack would be dequoting
here. Patch follows.

Thanks,
Ryan

From e5396b20d6e89bd19730bb9fa5ce90c3d0286857 Mon Sep 17 00:00:00 2001
From: Jon Bardin <j...@jbardin.local>
Date: Wed, 28 Apr 2010 17:43:55 -0700
Subject: [PATCH] added test for bug with escaping query string parameters

---
test/spec_rack_request.rb | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/test/spec_rack_request.rb b/test/spec_rack_request.rb
index fcdeb48..43a4b87 100644
--- a/test/spec_rack_request.rb
+++ b/test/spec_rack_request.rb
@@ -1,5 +1,6 @@
require 'test/spec'
require 'stringio'
+require 'cgi'

require 'rack/request'
require 'rack/mock'
@@ -542,4 +543,16 @@ EOF
req2.GET.should.equal "foo" => "bar"
req2.params.should.equal "foo" => "bar"
end
+
+ (0x20...0x7E).collect { |a|
+ b = a.chr
+ c = CGI.escape(b)
+ specify "should not strip '#{a}' => '#{c}' => '#{b}' escaped
character from parameters when accessed as string" do
+ url = "/?foo=#{c}bar#{c}"
+ env = Rack::MockRequest.env_for(url)
+ req2 = Rack::Request.new(env)
+ req2.GET.should.equal "foo" => "#{b}bar#{b}"
+ req2.params.should.equal "foo" => "#{b}bar#{b}"
+ end
+ }
end
--
1.7.0.5
Reply all
Reply to author
Forward
0 new messages