Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix copying top level symlinks to folders in directory unpack_strategy #6141

Merged
merged 1 commit into from May 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions Library/Homebrew/test/unpack_strategy/directory_spec.rb
Expand Up @@ -9,6 +9,8 @@
mktmpdir.tap do |path|
FileUtils.touch path/"file"
FileUtils.ln_s "file", path/"symlink"
FileUtils.mkdir path/"folder"
FileUtils.ln_s "folder", path/"folderSymlink"
end
}

Expand All @@ -19,6 +21,11 @@
expect(unpack_dir/"symlink").to be_a_symlink
end

it "does not follow top level symlinks to directories" do
strategy.extract(to: unpack_dir)
expect(unpack_dir/"folderSymlink").to be_a_symlink
end

it "preserves permissions of contained files" do
FileUtils.chmod 0644, path/"file"

Expand Down
3 changes: 2 additions & 1 deletion Library/Homebrew/unpack_strategy/directory.rb
Expand Up @@ -19,7 +19,8 @@ def self.can_extract?(path)
def extract_to_dir(unpack_dir, basename:, verbose:)
path.children.each do |child|
system_command! "cp",
args: ["-pR", child.directory? ? "#{child}/." : child, unpack_dir/child.basename],
args: ["-pR", (child.directory? && !child.symlink?) ? "#{child}/." : child,
unpack_dir/child.basename],
verbose: verbose
end
end
Expand Down