Skip to content

Commit b8547b7

Browse files
author
Morgan Haskel
committed
Merge pull request #310 from kainz/master
URI.escape for the array case was incorrect.
2 parents 055083c + 41baef8 commit b8547b7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/puppet/parser/functions/uriescape.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module Puppet::Parser::Functions
2222

2323
if value.is_a?(Array)
2424
# Numbers in Puppet are often string-encoded which is troublesome ...
25-
result = value.collect { |i| i.is_a?(String) ? URI.escape(i,unsafe) : i }
25+
result = value.collect { |i| i.is_a?(String) ? URI.escape(i) : i }
2626
else
2727
result = URI.escape(value)
2828
end

spec/functions/uriescape_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
expect(result).to(eq(':/?%23[]@!$&\'()*+,;=%20%22%7B%7D'))
1818
end
1919

20+
it "should uriescape an array of strings, while not touching up nonstrings" do
21+
teststring = ":/?#[]@!$&'()*+,;= \"{}"
22+
expectstring = ':/?%23[]@!$&\'()*+,;=%20%22%7B%7D'
23+
result = scope.function_uriescape([[teststring, teststring, 1]])
24+
expect(result).to(eq([expectstring, expectstring, 1]))
25+
end
26+
2027
it "should do nothing if a string is already safe" do
2128
result = scope.function_uriescape(["ABCdef"])
2229
expect(result).to(eq('ABCdef'))

0 commit comments

Comments
 (0)