1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Merge rubygems master from upstream.

I picked the commit from 3c469e0da538428a0ddd94f99aa73c32da22e8ba
This commit is contained in:
Hiroshi SHIBATA 2019-06-01 12:45:11 +03:00
parent 560cd5b1f0
commit 56660de3c6
55 changed files with 1051 additions and 1053 deletions

View file

@ -107,8 +107,8 @@ class Gem::Package::TarHeader
new :name => fields.shift,
:mode => strict_oct(fields.shift),
:uid => strict_oct(fields.shift),
:gid => strict_oct(fields.shift),
:uid => oct_or_256based(fields.shift),
:gid => oct_or_256based(fields.shift),
:size => strict_oct(fields.shift),
:mtime => strict_oct(fields.shift),
:checksum => strict_oct(fields.shift),
@ -130,6 +130,15 @@ class Gem::Package::TarHeader
raise ArgumentError, "#{str.inspect} is not an octal string"
end
def self.oct_or_256based(str)
# \x80 flags a positive 256-based number
# \ff flags a negative 256-based number
# In case we have a match, parse it as a signed binary value
# in big-endian order, except that the high-order bit is ignored.
return str.unpack('N2').last if str =~ /\A[\x80\xff]/n
strict_oct(str)
end
##
# Creates a new TarHeader using +vals+