1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #417 from croaker/master

Fixed the escaping in Fog::AWS.escape
This commit is contained in:
Wesley Beary 2011-07-13 10:23:59 -07:00
commit 876247d72b
2 changed files with 6 additions and 2 deletions

View file

@ -46,7 +46,9 @@ module Fog
end
def self.escape(string)
string.gsub( /([^-a-zA-Z0-9_.~]+)/n ) { |match| '%' + match.unpack( 'H2' * match.size ).join( '%' ).upcase }
string.gsub(/([^a-zA-Z0-9_.\-~]+)/) {
"%" + $1.unpack("H2" * $1.bytesize).join("%").upcase
}
end
def self.signed_params(params, options = {})

View file

@ -1,3 +1,5 @@
# encoding: utf-8
Shindo.tests('AWS | signed_params', ['aws']) do
returns( Fog::AWS.escape( "'Stop!' said Fred_-~." ) ) { "%27Stop%21%27%20said%20Fred_-~." }
returns( Fog::AWS.escape( "'Stöp!' said Fred_-~." ) ) { "%27St%C3%B6p%21%27%20said%20Fred_-~." }
end