Merge pull request #4507 from reitermarkus/unpack-symlink
Don't follow symlinks when unpacking a directory.
This commit is contained in:
commit
23be3cedda
@ -59,6 +59,22 @@ describe UnpackStrategy do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe DirectoryUnpackStrategy do
|
||||||
|
let(:path) {
|
||||||
|
mktmpdir.tap do |path|
|
||||||
|
FileUtils.touch path/"file"
|
||||||
|
FileUtils.ln_s "file", path/"symlink"
|
||||||
|
end
|
||||||
|
}
|
||||||
|
subject(:strategy) { described_class.new(path) }
|
||||||
|
let(:unpack_dir) { mktmpdir }
|
||||||
|
|
||||||
|
it "does not follow symlinks" do
|
||||||
|
strategy.extract(to: unpack_dir)
|
||||||
|
expect(unpack_dir/"symlink").to be_a_symlink
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe UncompressedUnpackStrategy do
|
describe UncompressedUnpackStrategy do
|
||||||
let(:path) {
|
let(:path) {
|
||||||
(mktmpdir/"test").tap do |path|
|
(mktmpdir/"test").tap do |path|
|
||||||
|
|||||||
@ -96,7 +96,7 @@ class DirectoryUnpackStrategy < UnpackStrategy
|
|||||||
private
|
private
|
||||||
|
|
||||||
def extract_to_dir(unpack_dir, basename:)
|
def extract_to_dir(unpack_dir, basename:)
|
||||||
FileUtils.cp_r path.children, unpack_dir, preserve: true
|
FileUtils.cp_r File.join(path, "."), unpack_dir, preserve: true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user