From: Maciej Lotkowski <maciej.lotkowski@gmail.com>
To: Rack Development <rack-devel@googlegroups.com>
Subject: Invalid query string handling
Date: Mon, 23 Nov 2009 04:41:13 -0800 (PST) [thread overview]
Message-ID: <4f56a124-ba2c-4336-989b-7a8336dc98f4@v37g2000vbb.googlegroups.com> (raw)
Hi,
recently I stumbled upon a problem:
require 'rubygems'
require 'rack'
require 'rack/mock'
app = lambda { |env|
Rack::Request.new(env).GET
}
app.call(Rack::MockRequest.env_for("/kiszka?foo=&foo[option]=kiszka"))
The call raises an exception due the invalid query string
TypeError: expected Hash (got String) for param `_REQUEST'
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/
rack-1.0.1/lib/rack/utils.rb:93:in `normalize_params'
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/
rack-1.0.1/lib/rack/utils.rb:62:in `parse_nested_query'
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/
rack-1.0.1/lib/rack/utils.rb:60:in `each'
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/
rack-1.0.1/lib/rack/utils.rb:60:in `parse_nested_query'
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/
rack-1.0.1/lib/rack/request.rb:119:in `GET'
As a workaround I've created a middleware which creates a
Rack::Request
instance, calls GET, catches TypeError if there is any and returns
BadRequest
if an error occured. What is the "right" way to handle this? I think
it would be
better to throw some InvalidQueryString exception from
Rack::Request#GET,
wouldn't it?
--
Maciej Lotkowski
next reply other threads:[~2009-11-23 15:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-23 12:41 Maciej Lotkowski [this message]
2009-11-24 9:18 ` Invalid query string handling James Tucker
2009-11-24 9:41 ` Maciej Lotkowski
2009-11-24 10:22 ` James Tucker
2009-11-24 9:25 ` Magnus Holm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://groups.google.com/group/rack-devel
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4f56a124-ba2c-4336-989b-7a8336dc98f4@v37g2000vbb.googlegroups.com \
--to=rack-devel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).