mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
parent
d2d6ccf116
commit
e9a72f1c9e
1 changed files with 8 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue