summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJordan Curzon <curzonj@gmail.com>2009-07-01 21:39:22 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-07-02 15:13:52 +1000
commitcdd166244ab55c9f3129bdbffd16bd55bd8ed10e (patch)
tree988d860a63c877e50b250f904bee786974945c40
parent769c8aa71e5b4855662314f13b1197853cdc843a (diff)
downloadpuppet-cdd166244ab55c9f3129bdbffd16bd55bd8ed10e.tar.gz
puppet-cdd166244ab55c9f3129bdbffd16bd55bd8ed10e.tar.xz
puppet-cdd166244ab55c9f3129bdbffd16bd55bd8ed10e.zip
Fixing #2238 - Deal with nil hash keys from mongrel params
Mongrel::HttpRequest.query_parse outputs a params hash with nil keys given certain query strings. Network::HTTP::Handler.decode_params needs to check the incoming values. Signed-off-by: Jordan Curzon <curzonj@gmail.com>
-rw-r--r--lib/puppet/network/http/handler.rb2
-rwxr-xr-xspec/unit/network/http/mongrel/rest.rb5
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb
index 9528d39a6..c6b809d30 100644
--- a/lib/puppet/network/http/handler.rb
+++ b/lib/puppet/network/http/handler.rb
@@ -182,6 +182,8 @@ module Puppet::Network::HTTP::Handler
def decode_params(params)
params.inject({}) do |result, ary|
param, value = ary
+ next result if param.blank?
+
param = param.to_sym
# These shouldn't be allowed to be set by clients
diff --git a/spec/unit/network/http/mongrel/rest.rb b/spec/unit/network/http/mongrel/rest.rb
index 5a5d2cfec..abd573a25 100755
--- a/spec/unit/network/http/mongrel/rest.rb
+++ b/spec/unit/network/http/mongrel/rest.rb
@@ -92,6 +92,11 @@ describe "Puppet::Network::HTTP::MongrelREST" do
@request.stubs(:params).returns({})
end
+ it "should skip empty parameter values" do
+ @request.expects(:params).returns('QUERY_STRING' => "&=")
+ lambda { @handler.params(@request) }.should_not raise_error
+ end
+
it "should include the HTTP request parameters, with the keys as symbols" do
@request.expects(:params).returns('QUERY_STRING' => 'foo=baz&bar=xyzzy')
result = @handler.params(@request)