Skip to content

Commit 41baef8

Browse files
kainzMorgan Haskel
authored and
Morgan Haskel
committed
URI.escape for the array case was incorrect.
The previous commit to uriescape() changed the implementation to use the ruby default escape list for URI.escape(), but did not change the call triggered when uriescape() was called on an array, triggering ruby errors.
1 parent 055083c commit 41baef8

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)