зеркало из https://github.com/github/fog.git
Merge pull request #2791 from nate/bugfix/remove-utf-normalization
Removed unicode NFC normalization of S3 object keys.
This commit is contained in:
Коммит
040fb95075
|
@ -62,7 +62,6 @@ Gem::Specification.new do |s|
|
|||
s.add_development_dependency('fission')
|
||||
s.add_development_dependency('pry')
|
||||
s.add_development_dependency('google-api-client', '~> 0.6', '>= 0.6.2')
|
||||
s.add_development_dependency('unf')
|
||||
|
||||
if ENV["FOG_USE_LIBVIRT"]
|
||||
s.add_development_dependency('ruby-libvirt','~> 0.5.0')
|
||||
|
|
|
@ -89,15 +89,6 @@ 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
|
||||
}
|
||||
|
|
|
@ -177,15 +177,6 @@ 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
|
||||
}
|
||||
|
|
|
@ -3,11 +3,15 @@
|
|||
Shindo.tests('AWS | signed_params', ['aws']) do
|
||||
returns( Fog::AWS.escape( "'Stöp!' said Fred_-~./" ) ) { "%27St%C3%B6p%21%27%20said%20Fred_-~.%2F" }
|
||||
|
||||
tests('Keys should be canonicalised using Unicode NFC') do
|
||||
returns( Fog::AWS.escape( ["00E9".to_i(16)].pack("U*") ) ) { "%C3%A9" }
|
||||
tests('Unicode characters should be escaped') do
|
||||
unicode = ["00E9".to_i(16)].pack("U*")
|
||||
escaped = "%C3%A9"
|
||||
returns( escaped ) { Fog::AWS.escape( unicode ) }
|
||||
end
|
||||
|
||||
tests('Characters with combining mark should be combined and then escaped') do
|
||||
returns( Fog::AWS.escape( ["0065".to_i(16), "0301".to_i(16)].pack("U*") ) ) { "%C3%A9" }
|
||||
end
|
||||
tests('Unicode characters with combining marks should be escaped') do
|
||||
unicode = ["0065".to_i(16), "0301".to_i(16)].pack("U*")
|
||||
escaped = "e%CC%81"
|
||||
returns( escaped ) { Fog::AWS.escape( unicode ) }
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче