Bug 271657 - unzip doesn't know infozip (beta)'s -O and -I options
Summary: unzip doesn't know infozip (beta)'s -O and -I options
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-26 14:30 UTC by Mingye Wang
Modified: 2023-06-27 17:01 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mingye Wang 2023-05-26 14:30:44 UTC
Info-ZIP's release engineering has stalled, but they have managed to tag a beta with the unzip-iconv patch integrated.[1]  Unzip 6.10b[2] introduces:
  [1]: https://en.wikipedia.org/wiki/Info-ZIP#Official_betas
  [2]: https://sourceforge.net/projects/infozip/files/unreleased%20Betas/UnZip%20betas/

  "  \"New\" options -I and -O (from a patch that has been out there awhile)",
  "  are used on UNIX to set the ISO and OEM code pages used for conversions.",
  [...]
  "  -I   [UNIX] ISO code page to use.",
  "  -O   [UNIX] OEM code page to use.",

Now as unheard-of as Info-UnZIP 6.10b is, the two options have actually been in use for a long time via unzip-iconv and Debian.[3]  Any East Asian person will probably point you to that fork of info-zip unzip to properly extra a Windows ZIP file.
  [3]: https://github.com/emergy/unzip/blob/master/debian/patches/04-unzip60-alt-iconv-utf8

Implementation-wise, libarchive has an encoding conversion function for ZIP files: just use archive_read_set_options() to set hdrencoding.  There's some very weird logic to decide whether to use -I or -O depending on the zip's originating system, but I would just advice you to ignore it.  There's also some logic to set defaults for these switches, but why even bother.

PS: Unzip 6.10b has a rewritten argument parser with long options. That's very new and seldom used, so let's not worry about it. It does make reading the code a lot less torturous -- hats off to that.
Comment 1 Mingye Wang 2023-05-26 16:24:40 UTC
So uh, the patch is at https://github.com/freebsd/freebsd-src/pull/752.
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-06-27 17:01:00 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a227908571da056f66abb7263f965331303bf02f

commit a227908571da056f66abb7263f965331303bf02f
Author:     Mingye Wang <arthur200126@gmail.com>
AuthorDate: 2023-06-27 16:54:12 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-06-27 16:55:26 +0000

    unzip: add -O/-I encoding support

    These are for compatibility with the info-zip version of unzip.

    PR: 271657
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/752

 usr.bin/unzip/unzip.1 |  6 +++++-
 usr.bin/unzip/unzip.c | 11 +++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)