Merge pull request #2318 from nirvdrum/more_unicode_jruby_cleanup

More unicode jruby cleanup.
This commit is contained in:
Kevin Menard 2013-10-24 11:01:19 -07:00
commit 9e1a29b9f3
2 changed files with 9 additions and 3 deletions

View File

@ -92,7 +92,7 @@ module Fog
def self.escape(string)
string = begin
Unicode::normalize_C(string)
::Unicode::normalize_C(string)
rescue
Fog::Logger.warning("Fog::AWS string escaping will not normalize Unicode characters on JRuby, pending a fix for issue #2279")
string

View File

@ -168,9 +168,15 @@ module Fog
"/#{escape(bucket_name.to_s)}#{path}"
end
# NOTE: differs fram Fog::AWS.escape by NOT escaping `/`
# NOTE: differs from Fog::AWS.escape by NOT escaping `/`
def escape(string)
string = Unicode::normalize_C(string)
string = begin
::Unicode::normalize_C(string)
rescue
Fog::Logger.warning("Fog::Storage::AWS string escaping will not normalize Unicode characters on JRuby, pending a fix for issue #2279")
string
end
string.gsub(/([^a-zA-Z0-9_.\-~\/]+)/) {
"%" + $1.unpack("H2" * $1.bytesize).join("%").upcase
}