File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -413,6 +413,8 @@ def extract_files(destination_dir, pattern = "*")
413413 # extracted.
414414
415415 def extract_tar_gz ( io , destination_dir , pattern = "*" ) # :nodoc:
416+ destination_dir = File . realpath ( destination_dir )
417+
416418 directories = [ ]
417419 symlinks = [ ]
418420
Original file line number Diff line number Diff line change @@ -573,6 +573,32 @@ def test_extract_tar_gz_symlink_relative_path
573573 File . read ( extracted )
574574 end
575575
576+ def test_extract_symlink_into_symlink_dir
577+ package = Gem ::Package . new @gem
578+ tgz_io = util_tar_gz do |tar |
579+ tar . mkdir "lib" , 0o755
580+ tar . add_symlink "lib/link" , "./inside.rb" , 0o644
581+ tar . add_file "lib/inside.rb" , 0o644 do |io |
582+ io . write "hi"
583+ end
584+ end
585+
586+ destination_subdir = File . join @destination , "subdir"
587+ FileUtils . mkdir_p destination_subdir
588+
589+ destination_linkdir = File . join @destination , "linkdir"
590+ File . symlink ( destination_subdir , destination_linkdir )
591+
592+ package . extract_tar_gz tgz_io , destination_linkdir
593+
594+ extracted = File . join destination_subdir , "lib/link"
595+ assert_path_exist extracted
596+ assert_equal "./inside.rb" ,
597+ File . readlink ( extracted )
598+ assert_equal "hi" ,
599+ File . read ( extracted )
600+ end
601+
576602 def test_extract_tar_gz_symlink_broken_relative_path
577603 package = Gem ::Package . new @gem
578604 package . verify
You can’t perform that action at this time.
0 commit comments