[rubygems/rubygems] Use String#unpack1 available since ruby 3.0

https://github.com/rubygems/rubygems/commit/46258d6cb4
This commit is contained in:
Martin Emde 2023-12-05 13:29:37 -08:00 committed by git
parent b8b319dd1a
commit d9a1bb4b09
3 changed files with 3 additions and 4 deletions

View File

@ -43,8 +43,7 @@ module Bundler
return digest if digest.match?(/\A[0-9a-f]{64}\z/i)
if digest.match?(%r{\A[-0-9a-z_+/]{43}={0,2}\z}i)
digest = digest.tr("-_", "+/") # fix urlsafe base64
# transform to hex. Use unpack1 when we drop older rubies
return digest.unpack("m0").first.unpack("H*").first
return digest.unpack1("m0").unpack1("H*")
end
raise ArgumentError, "#{digest.inspect} is not a valid SHA256 hex or base64 digest"
end

View File

@ -50,7 +50,7 @@ module Bundler
words.map!.with_index {|word, index| SHA1_MASK & (word + mutated[index]) }
end
words.pack("N*").unpack("H*").first
words.pack("N*").unpack1("H*")
end
private

View File

@ -70,7 +70,7 @@ class Gem::Package::Old < Gem::Package
file_data << line
end
file_data = file_data.strip.unpack("m")[0]
file_data = file_data.strip.unpack1("m")
file_data = Zlib::Inflate.inflate file_data
raise Gem::Package::FormatError, "#{full_name} in #{@gem} is corrupt" if