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

[aws] narrow scope of unf warning

see #2320
This commit is contained in:
geemus 2013-11-11 09:06:42 -06:00
parent d2d6ccf116
commit e9a72f1c9e

View file

@ -2,12 +2,6 @@ require 'fog/core'
require 'fog/aws/credential_fetcher'
require 'fog/aws/signaturev4'
begin
require 'unf/normalizer'
rescue LoadError
Fog::Logger.warning("Unable to load the 'unf' gem. Your AWS strings may not be properly encoded.")
end
module Fog
module AWS
extend Fog::Provider
@ -92,6 +86,14 @@ module Fog
end
def self.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