Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tnsmart

macrumors 6502
Original poster
Aug 23, 2008
278
24
If I do:

Code:
$ cd ~/Desktop
$ mkdir test_dir
$ cd test_dir/
$ mkdir test_subdir_1 test_subdir_2
$ touch test_subdir_1/test_file.txt
$ cd test_subdir_2/
$ zip test_archive.zip ../test_subdir_1/*
  adding: ../test_subdir_1/test_file.txt (stored 0%)


and then I go to test_subdir_2 in Finder and try to open test_archive.zip, I get:

Screen Shot 2021-02-13 at 11.12.11 PM.png


However, if I extract test_archive.zip with The Unarchiver, it gives me __Parent__/test_subdir_1/test_file.txt. And, I can do:
Code:
$ unzip test_archive.zip
Archive:  test_archive.zip
warning:  skipped "../" path component(s) in ../test_subdir_1/test_file.txt
extracting: test_subdir_1/test_file.txt
$ ll
total 8
-rw-r--r--  1 Thomas  staff  210 Feb 13 23:23 test_archive.zip
drwxr-xr-x  3 Thomas  staff   96 Feb 13 23:23 test_subdir_1
$ ll test_subdir_1/
total 0
-rw-r--r--  1 Thomas  staff  0 Feb 13 23:23 test_file.txt


I don't have this problem if I create the zip archive in the directory containing the files.

macOS 11.0.1
Code:
$ zip -v
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
This is Zip 3.0 (July 5th 2008), by Info-ZIP.

Any idea why I have this problem with Finder or how I can avoid it? Is this a bug?

Thanks!
 

chown33

Moderator
Staff member
Aug 9, 2009
11,004
8,901
A sea of green
It seems like a bug to me, and my guess is that it's related to the "..". I tried your procedure under an older OS version, and it unzipped fine when double-clicked in Finder.

I suggest confirming what's actually in the zip file by looking at the listing of it:
Code:
unzip -l test_archive.zip
Make sure it really has a ".." directory reference in the path. Judging by the output from your unzip command, it does.

Try working around this by not making zip files with ".." directory references. As a test, see what happens to the pathnames in the zip with the -j and -jj options. You can try unzipping those from the Finder, to see how it handles them.

I think you should report the bug to Apple, including both the procedure for making the zip file (i.e. what you posted above), and attaching the malfunctioning zip file (if possible).

Here's a bit of info on reporting bugs to Apple:

I found that by searching for: report mac bug to apple
 

tnsmart

macrumors 6502
Original poster
Aug 23, 2008
278
24
Thanks for your reply!

Code:
$ unzip -l test_archive.zip
Archive:  test_archive.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  02-14-2021 12:50   ../test_subdir_1/test_file.txt
---------                     -------
        0                     1 file

With '-j':
Code:
MacBook-Pro-4:test_subdir_2 Thomas$ cd ~/Desktop
MacBook-Pro-4:Desktop Thomas$ rm -r test_dir
MacBook-Pro-4:Desktop Thomas$ mkdir test_dir
MacBook-Pro-4:Desktop Thomas$ cd test_dir/
MacBook-Pro-4:test_dir Thomas$ mkdir test_subdir_1 test_subdir_2
MacBook-Pro-4:test_dir Thomas$ touch test_subdir_1/test_file.txt
MacBook-Pro-4:test_dir Thomas$ cd test_subdir_2/
MacBook-Pro-4:test_subdir_2 Thomas$ zip -j test_archive.zip ../test_subdir_1/*
  adding: test_file.txt (stored 0%)
MacBook-Pro-4:test_subdir_2 Thomas$ unzip -l test_archive.zip
Archive:  test_archive.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  02-14-2021 12:55   test_file.txt
---------                     -------
        0                     1 file
MacBook-Pro-4:test_subdir_2 Thomas$

With '-jj':
Code:
MacBook-Pro-4:test_subdir_2 Thomas$ cd ~/Desktop
MacBook-Pro-4:Desktop Thomas$ rm -r test_dir
MacBook-Pro-4:Desktop Thomas$ mkdir test_dir
MacBook-Pro-4:Desktop Thomas$ cd test_dir/
MacBook-Pro-4:test_dir Thomas$ mkdir test_subdir_1 test_subdir_2
MacBook-Pro-4:test_dir Thomas$ touch test_subdir_1/test_file.txt
MacBook-Pro-4:test_dir Thomas$ cd test_subdir_2/
MacBook-Pro-4:test_subdir_2 Thomas$ zip -jj test_archive.zip ../test_subdir_1/*
  adding: test_file.txt (stored 0%)
MacBook-Pro-4:test_subdir_2 Thomas$ unzip -l test_archive.zip
Archive:  test_archive.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  02-14-2021 12:56   test_file.txt
---------                     -------
        0                     1 file
MacBook-Pro-4:test_subdir_2 Thomas$

Attached file created with:
Code:
MacBook-Pro-4:Desktop Thomas$ cd ~/Desktop/
MacBook-Pro-4:Desktop Thomas$ zip -r test_dir.zip test_dir
  adding: test_dir/ (stored 0%)
  adding: test_dir/test_subdir_2/ (stored 0%)
  adding: test_dir/test_subdir_2/test_archive.zip (stored 0%)
  adding: test_dir/test_subdir_1/ (stored 0%)
  adding: test_dir/test_subdir_1/test_file.txt (stored 0%)
MacBook-Pro-4:Desktop Thomas$

I will submit a bug report to Apple and reference this post.
 

Attachments

  • test_dir.zip
    1.1 KB · Views: 101
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.