diff options
author | Luke Kanies <luke@madstop.com> | 2009-02-14 17:35:34 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2009-02-18 22:38:43 -0600 |
commit | 7bc41cefa0115067a2e9aab3dbd1924667c46dfe (patch) | |
tree | fb2ae6dad4610ae6d6d633c1aedde514e5568afb /lib/puppet/network/http/handler.rb | |
parent | 992231a58daf8f0b489022f0af8ddcfb615bb0e1 (diff) | |
download | puppet-7bc41cefa0115067a2e9aab3dbd1924667c46dfe.tar.gz puppet-7bc41cefa0115067a2e9aab3dbd1924667c46dfe.tar.xz puppet-7bc41cefa0115067a2e9aab3dbd1924667c46dfe.zip |
Adding clarity to query string handling in REST calls
We previously only handled simple strings as values,
but we know handle true and false as booleans, we URI-escape
all strings, and we can yaml-encode and then escape arrays of
strings.
This could get abused a bit, in that we're just yaml-dumping anything
that's an array, but it should be pretty safe. Mmmm, should.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/network/http/handler.rb')
-rw-r--r-- | lib/puppet/network/http/handler.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb index 7af0528eb..9bc94a037 100644 --- a/lib/puppet/network/http/handler.rb +++ b/lib/puppet/network/http/handler.rb @@ -180,4 +180,19 @@ module Puppet::Network::HTTP::Handler def params(request) raise NotImplementedError end + + def decode_params(params) + params.inject({}) do |result, ary| + param, value = ary + value = URI.unescape(value) + if value =~ /^---/ + value = YAML.load(value) + else + value = true if value == "true" + value = false if value == "false" + end + result[param.to_sym] = value + result + end + end end |