diff --git a/dalli.gemspec b/dalli.gemspec index 723eab97..99ea6611 100644 --- a/dalli.gemspec +++ b/dalli.gemspec @@ -22,6 +22,4 @@ Gem::Specification.new do |s| s.metadata = { 'rubygems_mfa_required' => 'true' } - - s.add_dependency 'base64' end diff --git a/lib/dalli/protocol/meta/key_regularizer.rb b/lib/dalli/protocol/meta/key_regularizer.rb index eeb2b6a2..56b18605 100644 --- a/lib/dalli/protocol/meta/key_regularizer.rb +++ b/lib/dalli/protocol/meta/key_regularizer.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'base64' - module Dalli module Protocol class Meta @@ -17,13 +15,15 @@ class KeyRegularizer def self.encode(key) return [key, false] if key.ascii_only? && !WHITESPACE.match(key) - [Base64.strict_encode64(key), true] + strict_base64_encoded = [key].pack('m0') + [strict_base64_encoded, true] end def self.decode(encoded_key, base64_encoded) return encoded_key unless base64_encoded - Base64.strict_decode64(encoded_key).force_encoding(Encoding::UTF_8) + strict_base64_decoded = encoded_key.unpack1('m0') + strict_base64_decoded.force_encoding(Encoding::UTF_8) end end end