ruby-changes:61084
From: Dmytro <ko1@a...>
Date: Fri, 8 May 2020 14:13:55 +0900 (JST)
Subject: [ruby-changes:61084] 03fe7da186 (master): [rubygems/rubygems] Allow spaces in file headers during octal check
https://git.ruby-lang.org/ruby.git/commit/?id=03fe7da186 From 03fe7da186ff239a3cebaca3f2ce1e1c4b7d243f Mon Sep 17 00:00:00 2001 From: Dmytro Shyrshov <shirshov.dmitriy@g...> Date: Thu, 20 Feb 2020 22:07:40 +0200 Subject: [rubygems/rubygems] Allow spaces in file headers during octal check https://github.com/rubygems/rubygems/commit/e9e25731d8 diff --git a/lib/rubygems/package/tar_header.rb b/lib/rubygems/package/tar_header.rb index c376127..83a208b 100644 --- a/lib/rubygems/package/tar_header.rb +++ b/lib/rubygems/package/tar_header.rb @@ -126,7 +126,8 @@ class Gem::Package::TarHeader https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package/tar_header.rb#L126 end def self.strict_oct(str) - return str.oct if str =~ /\A[0-7]*\z/ + return str.strip.oct if str.strip =~ /\A[0-7]*\z/ + raise ArgumentError, "#{str.inspect} is not an octal string" end diff --git a/test/rubygems/test_gem_package_tar_header.rb b/test/rubygems/test_gem_package_tar_header.rb index 7e59073..3629e6b 100644 --- a/test/rubygems/test_gem_package_tar_header.rb +++ b/test/rubygems/test_gem_package_tar_header.rb @@ -205,4 +205,23 @@ tjmather\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package_tar_header.rb#L205 assert_equal 6932, tar_header.checksum end + def test_spaces_in_headers + stream = StringIO.new( + <<-EOF.dup.force_encoding('binary').split("\n").join +Access_Points_09202018.csv +\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 +\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 +\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 +\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 +\x00\x00100777 \x00 0 \x00 0 \x00 4357 13545040367 104501 +\x000 + EOF + ) + + tar_header = Gem::Package::TarHeader.from stream + + assert_equal 0, tar_header.uid + assert_equal 0, tar_header.gid + end + end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/