[rubygems/rubygems] Use String#unpack1 available since ruby 3.0
https://github.com/rubygems/rubygems/commit/46258d6cb4
This commit is contained in:
parent
b8b319dd1a
commit
d9a1bb4b09
@ -43,8 +43,7 @@ module Bundler
|
|||||||
return digest if digest.match?(/\A[0-9a-f]{64}\z/i)
|
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)
|
if digest.match?(%r{\A[-0-9a-z_+/]{43}={0,2}\z}i)
|
||||||
digest = digest.tr("-_", "+/") # fix urlsafe base64
|
digest = digest.tr("-_", "+/") # fix urlsafe base64
|
||||||
# transform to hex. Use unpack1 when we drop older rubies
|
return digest.unpack1("m0").unpack1("H*")
|
||||||
return digest.unpack("m0").first.unpack("H*").first
|
|
||||||
end
|
end
|
||||||
raise ArgumentError, "#{digest.inspect} is not a valid SHA256 hex or base64 digest"
|
raise ArgumentError, "#{digest.inspect} is not a valid SHA256 hex or base64 digest"
|
||||||
end
|
end
|
||||||
|
@ -50,7 +50,7 @@ module Bundler
|
|||||||
words.map!.with_index {|word, index| SHA1_MASK & (word + mutated[index]) }
|
words.map!.with_index {|word, index| SHA1_MASK & (word + mutated[index]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
words.pack("N*").unpack("H*").first
|
words.pack("N*").unpack1("H*")
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -70,7 +70,7 @@ class Gem::Package::Old < Gem::Package
|
|||||||
file_data << line
|
file_data << line
|
||||||
end
|
end
|
||||||
|
|
||||||
file_data = file_data.strip.unpack("m")[0]
|
file_data = file_data.strip.unpack1("m")
|
||||||
file_data = Zlib::Inflate.inflate file_data
|
file_data = Zlib::Inflate.inflate file_data
|
||||||
|
|
||||||
raise Gem::Package::FormatError, "#{full_name} in #{@gem} is corrupt" if
|
raise Gem::Package::FormatError, "#{full_name} in #{@gem} is corrupt" if
|
||||||
|
Loading…
x
Reference in New Issue
Block a user