diff options
author | Morgan Haskel <morgan@puppetlabs.com> | 2015-03-03 16:06:46 -0800 |
---|---|---|
committer | Morgan Haskel <morgan@puppetlabs.com> | 2015-03-03 16:06:46 -0800 |
commit | b8547b7c29801ca3d89230dfc95716d6f93040ab (patch) | |
tree | 9b5cd020602d8260bd4215881349260e20d5a026 | |
parent | 055083c117f79e03e7313f328f9e3e338d4dc6a9 (diff) | |
parent | 41baef8502eabd34dc4fe49f43c6ef7c61f8e6c3 (diff) | |
download | puppet-stdlib-b8547b7c29801ca3d89230dfc95716d6f93040ab.tar.gz puppet-stdlib-b8547b7c29801ca3d89230dfc95716d6f93040ab.tar.bz2 |
Merge pull request #310 from kainz/master
URI.escape for the array case was incorrect.
-rw-r--r-- | lib/puppet/parser/functions/uriescape.rb | 2 | ||||
-rwxr-xr-x | spec/functions/uriescape_spec.rb | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/puppet/parser/functions/uriescape.rb b/lib/puppet/parser/functions/uriescape.rb index a486eee..45bbed2 100644 --- a/lib/puppet/parser/functions/uriescape.rb +++ b/lib/puppet/parser/functions/uriescape.rb @@ -22,7 +22,7 @@ module Puppet::Parser::Functions if value.is_a?(Array) # Numbers in Puppet are often string-encoded which is troublesome ... - result = value.collect { |i| i.is_a?(String) ? URI.escape(i,unsafe) : i } + result = value.collect { |i| i.is_a?(String) ? URI.escape(i) : i } else result = URI.escape(value) end diff --git a/spec/functions/uriescape_spec.rb b/spec/functions/uriescape_spec.rb index 2321e5a..d0f37de 100755 --- a/spec/functions/uriescape_spec.rb +++ b/spec/functions/uriescape_spec.rb @@ -17,6 +17,13 @@ describe "the uriescape function" do expect(result).to(eq(':/?%23[]@!$&\'()*+,;=%20%22%7B%7D')) end + it "should uriescape an array of strings, while not touching up nonstrings" do + teststring = ":/?#[]@!$&'()*+,;= \"{}" + expectstring = ':/?%23[]@!$&\'()*+,;=%20%22%7B%7D' + result = scope.function_uriescape([[teststring, teststring, 1]]) + expect(result).to(eq([expectstring, expectstring, 1])) + end + it "should do nothing if a string is already safe" do result = scope.function_uriescape(["ABCdef"]) expect(result).to(eq('ABCdef')) |