From f28ac60ab20c70dc8d0b55104dcd20142a49ef4b Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Thu, 24 Oct 2013 10:59:41 -0400 Subject: [PATCH 1/2] Scope the Unicode module so NameErrors make more sense. --- lib/fog/aws.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/aws.rb b/lib/fog/aws.rb index 30ed08476..ad41b990e 100644 --- a/lib/fog/aws.rb +++ b/lib/fog/aws.rb @@ -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 From dabed804b08abc192a91502b76f1ce40fffbd6f9 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Thu, 24 Oct 2013 11:01:43 -0400 Subject: [PATCH 2/2] Handle another case of the 'unicode' gem breaking things on JRuby. This is was an omission from pull request #2315. --- lib/fog/aws/storage.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/fog/aws/storage.rb b/lib/fog/aws/storage.rb index 69c7680da..794145062 100644 --- a/lib/fog/aws/storage.rb +++ b/lib/fog/aws/storage.rb @@ -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 }