From: Adrian Vovk Date: Sat, 22 Jul 2023 09:00:20 +0000 (-0400) Subject: unzip: Pull in upstream updates (#1926) X-Git-Tag: v3.7.1~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad5e8360867f6dec7eba55ce54be2365a84c7ef4;p=thirdparty%2Flibarchive.git unzip: Pull in upstream updates (#1926) Fixes #1873 --- diff --git a/unzip/bsdunzip.1 b/unzip/bsdunzip.1 index 3c656ebc4..dda01e7b8 100644 --- a/unzip/bsdunzip.1 +++ b/unzip/bsdunzip.1 @@ -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 diff --git a/unzip/bsdunzip.c b/unzip/bsdunzip.c index cd8237aa7..0b6506a18 100644 --- a/unzip/bsdunzip.c +++ b/unzip/bsdunzip.c @@ -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;