Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions dalli.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@ Gem::Specification.new do |s|
s.metadata = {
'rubygems_mfa_required' => 'true'
}

s.add_dependency 'base64'
end
8 changes: 4 additions & 4 deletions lib/dalli/protocol/meta/key_regularizer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'base64'

module Dalli
module Protocol
class Meta
Expand All @@ -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
Expand Down