diff --git a/lib/fog/providers/aws.rb b/lib/fog/providers/aws.rb index 9138da2eb..7ef39795c 100644 --- a/lib/fog/providers/aws.rb +++ b/lib/fog/providers/aws.rb @@ -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 = {}) diff --git a/tests/aws/signed_params_tests.rb b/tests/aws/signed_params_tests.rb index 24ffec3d0..1df3950de 100644 --- a/tests/aws/signed_params_tests.rb +++ b/tests/aws/signed_params_tests.rb @@ -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