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 <[email protected]>
---
 lib/puppet/network/http/handler.rb     |    2 ++
 spec/unit/network/http/mongrel/rest.rb |    5 +++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/lib/puppet/network/http/handler.rb 
b/lib/puppet/network/http/handler.rb
index 9528d39..c6b809d 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 5a5d2cf..abd573a 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)
-- 
1.6.3.3


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to