mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
Merge pull request #4619 from inspec/zenspider/empty-tarball
Fix TarProvider when the tarball has empty files in it.
This commit is contained in:
commit
dd3043a992
3 changed files with 7 additions and 1 deletions
|
@ -171,7 +171,7 @@ module Inspec
|
|||
path = Pathname.new(name).relative_path_from(here).to_s
|
||||
|
||||
@contents[path] = begin # not ||= in a tarball, last one wins
|
||||
res = entry.read
|
||||
res = entry.read || ""
|
||||
try = res.dup
|
||||
try.force_encoding Encoding::UTF_8
|
||||
res = try if try.valid_encoding?
|
||||
|
|
BIN
test/fixtures/contains-empty-file-0.1.0.tar.gz
vendored
Normal file
BIN
test/fixtures/contains-empty-file-0.1.0.tar.gz
vendored
Normal file
Binary file not shown.
|
@ -185,6 +185,12 @@ describe Inspec::TarProvider do
|
|||
it "must read the contents of the file" do
|
||||
_(subject.read("inspec.yml")).must_match(/^name: complete$/)
|
||||
end
|
||||
|
||||
it "deals with empty files in tarballs correctly" do
|
||||
path = "test/fixtures/contains-empty-file-0.1.0.tar.gz"
|
||||
f = Inspec::FileProvider.for_path(path)
|
||||
_(f.files.grep(/empty/)).wont_be_empty
|
||||
end
|
||||
end
|
||||
|
||||
Entry = Struct.new(:full_name) do
|
||||
|
|
Loading…
Reference in a new issue