]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
unzip: Pull in upstream updates (#1926)
authorAdrian Vovk <adrianvovk@gmail.com>
Sat, 22 Jul 2023 09:00:20 +0000 (05:00 -0400)
committerMartin Matuska <martin.matuska@axelspringer.com>
Sat, 22 Jul 2023 09:00:52 +0000 (11:00 +0200)
Fixes #1873

unzip/bsdunzip.1
unzip/bsdunzip.c

index 3c656ebc46e268875d3fbe1351e5243c061bdb6e..dda01e7b84d70cab04c241e19e2c3362e2907544 100644 (file)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 2, 2023
+.Dd June 27, 2023
 .Dt BSDUNZIP 1
 .Os
 .Sh NAME
@@ -34,6 +34,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl aCcfjLlnopqtuvy
+.Op { Fl O | Fl I No } Ar encoding
 .Op Fl d Ar dir
 .Op Fl x Ar pattern
 .Op Fl P Ar password
@@ -62,6 +63,9 @@ Update existing.
 Extract only files from the zipfile if a file with the same name
 already exists on disk and is older than the former.
 Otherwise, the file is silently skipped.
+.It Fl I Ar encoding
+.It Fl O Ar encoding
+Convert filenames from the specified encoding.
 .It Fl j
 Ignore directories stored in the zipfile; instead, extract all files
 directly into the extraction directory.
@@ -123,7 +127,7 @@ Currently only
 mode 1 is supported, which lists the file names one per line.
 .It Ar [member ...]
 Optional list of members to extract from the zipfile.
-Can include patterns, e.g.
+Can include patterns, e.g.,
 .Ar 'memberdir/*'
 will extract all files and dirs below memberdir.
 .El
index cd8237aa7059fe6912ce5c8ba67fa6b396e480d8..0b6506a18adc9406fd8e0d1e4a738299fce77d87 100644 (file)
@@ -90,6 +90,7 @@ static int             C_opt;         /* match case-insensitively */
 static int              c_opt;         /* extract to stdout */
 static const char      *d_arg;         /* directory */
 static int              f_opt;         /* update existing files only */
+static char            *O_arg;         /* encoding */
 static int              j_opt;         /* junk directories */
 static int              L_opt;         /* lowercase names */
 static int              n_opt;         /* never overwrite */
@@ -998,6 +999,9 @@ unzip(const char *fn)
 
        ac(archive_read_support_format_zip(a));
 
+       if (O_arg)
+               ac(archive_read_set_format_option(a, "zip", "hdrcharset", O_arg));
+
        if (P_arg)
                archive_read_add_passphrase(a, P_arg);
        else
@@ -1080,7 +1084,7 @@ usage(void)
 {
 
        fprintf(stderr,
-"Usage: unzip [-aCcfjLlnopqtuvyZ1] [-d dir] [-x pattern] [-P password] zipfile\n"
+"Usage: unzip [-aCcfjLlnopqtuvyZ1] [{-O|-I} encoding] [-d dir] [-x pattern] [-P password] zipfile\n"
 "             [member ...]\n");
        exit(EXIT_FAILURE);
 }
@@ -1094,7 +1098,7 @@ getopts(int argc, char *argv[])
 #ifdef HAVE_GETOPT_OPTRESET
        optreset = 1;
 #endif
-       while ((opt = getopt(argc, argv, "aCcd:fjLlnopP:qtuvx:yZ1")) != -1)
+       while ((opt = getopt(argc, argv, "aCcd:fI:jLlnO:opP:qtuvx:yZ1")) != -1)
                switch (opt) {
                case '1':
                        Z1_opt = 1;
@@ -1114,6 +1118,10 @@ getopts(int argc, char *argv[])
                case 'f':
                        f_opt = 1;
                        break;
+               case 'I':
+               case 'O':
+                       O_arg = optarg;
+                       break;
                case 'j':
                        j_opt = 1;
                        break;