diff options
author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-07-16 20:53:36 +0200 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-07-17 18:16:06 +1000 |
commit | 8f8240763b0a8ab74b5b78eeb2372a2aa7848049 (patch) | |
tree | 166be7400b18beb81560b1824d739bb876ac38f1 /spec/unit/configurer | |
parent | c86d44ed826b99752fd0ee85b2a77eaadd8a57ae (diff) | |
download | puppet-8f8240763b0a8ab74b5b78eeb2372a2aa7848049.tar.gz puppet-8f8240763b0a8ab74b5b78eeb2372a2aa7848049.tar.xz puppet-8f8240763b0a8ab74b5b78eeb2372a2aa7848049.zip |
Fix #2261 - Make sure query string parameters are properly escaped
The problem is that URI.escape by default doesn't escape '+' (and
some other characters). But some web framework (at least webrick)
unescape the query string behind Puppet's back changing all '+'
to spaces corrupting facts containing '+' characters (like base64
encoded values).
The current fix makes sure we use CGI.escape for all query string
parameters. Indirection keys/path are still using URI escaping because
this part of the URI format shouldn't be handled like query string
parameters (otherwise '/' url separators are encoded which changes
the uri path).
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/configurer')
-rwxr-xr-x | spec/unit/configurer/fact_handler.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/spec/unit/configurer/fact_handler.rb b/spec/unit/configurer/fact_handler.rb index f615c0897..0c4af9554 100755 --- a/spec/unit/configurer/fact_handler.rb +++ b/spec/unit/configurer/fact_handler.rb @@ -95,10 +95,20 @@ describe Puppet::Configurer::FactHandler do end # I couldn't get marshal to work for this, only yaml, so we hard-code yaml. - it "should serialize and URI escape the fact values for uploading" do + it "should serialize and CGI escape the fact values for uploading" do facts = stub 'facts' facts.expects(:render).returns "my text" - text = URI.escape("my text") + text = CGI.escape("my text") + + @facthandler.expects(:find_facts).returns facts + + @facthandler.facts_for_uploading.should == {:facts_format => :yaml, :facts => text} + end + + it "should properly accept facts containing a '+'" do + facts = stub 'facts' + facts.expects(:render).returns "my+text" + text = "my%2Btext" @facthandler.expects(:find_facts).returns facts @@ -108,7 +118,7 @@ describe Puppet::Configurer::FactHandler do it "should hard-code yaml as the serialization" do facts = stub 'facts' facts.expects(:render).with(:yaml).returns "my text" - text = URI.escape("my text") + text = CGI.escape("my text") @facthandler.expects(:find_facts).returns facts |