diff options
-rw-r--r-- | lib/rubygems/package/tar_header.rb | 38 |
1 files changed, 21 insertions, 17 deletions
@@ -127,7 +127,8 @@ class Gem::Package::TarHeader end def self.strict_oct(str) - return str.strip.oct if /\A[0-7]*\z/.match?(str.strip) raise ArgumentError, "#{str.inspect} is not an octal string" end @@ -137,7 +138,8 @@ class Gem::Package::TarHeader # \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 /\A[\x80\xff]/n.match?(str) strict_oct(str) end @@ -149,21 +151,23 @@ class Gem::Package::TarHeader raise ArgumentError, ":name, :size, :prefix and :mode required" end - vals[:uid] ||= 0 - vals[:gid] ||= 0 - vals[:mtime] ||= 0 - vals[:checksum] ||= "" - vals[:typeflag] = "0" if vals[:typeflag].nil? || vals[:typeflag].empty? - vals[:magic] ||= "ustar" - vals[:version] ||= "00" - vals[:uname] ||= "wheel" - vals[:gname] ||= "wheel" - vals[:devmajor] ||= 0 - vals[:devminor] ||= 0 - - FIELDS.each do |name| - instance_variable_set "@#{name}", vals[name] - end @empty = vals[:empty] end |