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

Merge pull request #2320 from nirvdrum/replace_unicode_with_unf

Replaced the 'unicode' gem with 'unf' so it'll work with JRuby.
This commit is contained in:
Wesley Beary 2013-10-25 08:01:55 -07:00
commit d8b5bb7190
3 changed files with 5 additions and 17 deletions

View file

@ -50,7 +50,6 @@ Gem::Specification.new do |s|
s.add_dependency('net-ssh', '>=2.1.3')
s.add_dependency('nokogiri', '~>1.5')
s.add_dependency('ruby-hmac')
s.add_dependency('unicode', "~> 0.4.4") unless RUBY_PLATFORM == 'java'
## List your development dependencies here. Development dependencies are
## those that are only needed during development

View file

@ -1,10 +1,11 @@
require 'fog/core'
require 'fog/aws/credential_fetcher'
require 'fog/aws/signaturev4'
begin
require 'unicode'
require 'unf/normalizer'
rescue LoadError
# Temporarily ignored. This should only impact JRuby.
Fog::Logger.warning("Unable to load the 'unf' gem. Your AWS strings may not be properly encoded.")
end
module Fog
@ -91,13 +92,7 @@ module Fog
end
def self.escape(string)
string = begin
::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
end
string = defined?(::UNF::Normalizer) ? ::UNF::Normalizer.normalize(string, :nfc) : string
string.gsub(/([^a-zA-Z0-9_.\-~]+)/) {
"%" + $1.unpack("H2" * $1.bytesize).join("%").upcase
}

View file

@ -170,13 +170,7 @@ module Fog
# NOTE: differs from Fog::AWS.escape by NOT escaping `/`
def escape(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 = defined?(::UNF::Normalizer) ? ::UNF::Normalizer.normalize(string, :nfc) : string
string.gsub(/([^a-zA-Z0-9_.\-~\/]+)/) {
"%" + $1.unpack("H2" * $1.bytesize).join("%").upcase
}