Skip to content

Commit

Permalink
Merge branch 'uriescape-use_default_escape_list'
Browse files Browse the repository at this point in the history
This closes GH-164
  • Loading branch information
adrienthebo committed Jul 22, 2013
2 parents e0d4588 + b2e23dc commit e8dcc69
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/puppet/parser/functions/uriescape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module Puppet::Parser::Functions

value = arguments[0]
klass = value.class
unsafe = ":/?#[]@!$&'()*+,;= "

unless [Array, String].include?(klass)
raise(Puppet::ParseError, 'uriescape(): Requires either ' +
Expand All @@ -26,7 +25,7 @@ module Puppet::Parser::Functions
# Numbers in Puppet are often string-encoded which is troublesome ...
result = value.collect { |i| i.is_a?(String) ? URI.escape(i,unsafe) : i }
else
result = URI.escape(value,unsafe)
result = URI.escape(value)
end

return result
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/puppet/parser/functions/uriescape_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
end

it "should uriescape a string" do
result = scope.function_uriescape([":/?#[]@!$&'()*+,;= "])
result.should(eq('%3A%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D%20'))
result = scope.function_uriescape([":/?#[]@!$&'()*+,;= \"{}"])
result.should(eq(':/?%23[]@!$&\'()*+,;=%20%22%7B%7D'))
end

it "should do nothing if a string is already safe" do
Expand Down

0 comments on commit e8dcc69

Please sign in to comment.