From 245869d1b3b448079699956ee62f2e756d29555d Mon Sep 17 00:00:00 2001 From: geemus Date: Fri, 15 Nov 2013 10:04:37 -0600 Subject: [PATCH] [aws|storage] warn/load unf as needed --- lib/fog/aws/storage.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/fog/aws/storage.rb b/lib/fog/aws/storage.rb index ef487e6e0..9bc560191 100644 --- a/lib/fog/aws/storage.rb +++ b/lib/fog/aws/storage.rb @@ -174,6 +174,14 @@ module Fog # NOTE: differs from Fog::AWS.escape by NOT escaping `/` def escape(string) + unless @unf_loaded_or_warned + begin + require('unf/normalizer') + rescue LoadError + Fog::Logger.warning("Unable to load the 'unf' gem. Your AWS strings may not be properly encoded.") + end + @unf_loaded_or_warned = true + end string = defined?(::UNF::Normalizer) ? ::UNF::Normalizer.normalize(string, :nfc) : string string.gsub(/([^a-zA-Z0-9_.\-~\/]+)/) { "%" + $1.unpack("H2" * $1.bytesize).join("%").upcase