git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] test-lib: stricter unzip(1) check

From
EWEric Wong <e@80x24.org>
Date
Jul 18, 2016, 21:19 UTC
Message-ID
<20160718211951.GA62657@plume>
In-Reply-To
<xmqqk2giitrn.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> wrote:
Show 16 quoted lines
> Eric Wong <e@80x24.org> writes:
> > Junio C Hamano <gitster@pobox.com> wrote:
> >> +test_lazy_prereq UNZIP_AUTOTEXT '
> >> +	(
> >> +		mkdir unzip-autotext &&
> >> +		cd unzip-autotext
> >> +		"$GIT_UNZIP" -a "$TEST_DIRECTORY"/t5003/infozip-text.zip &&
> >> +		test -f text
> >> +	)
> >
> > /usr/bin/unzip actually takes -a on FreeBSD, just not in the
> > same way the Info-ZIP version does, so I suspect "test -f"
> > here is not enough.
> 
> Hmph.  So it only and always does "CRLF -> LF", while Info-ZIP
> version does something like autocrlf?

No, it does CRLF -> LF based on the absence of non-ASCII characters and ignoring metadata set in the zipfile. The unzip manpage states:

     Normally, the -a option should only affect files which are
     marked as text files in the zipfile's central directory.  Since
     the archive(3) library reads zipfiles sequentially, and does
     not use the central directory, that information is not available
     to the unzip utility.  Instead, the unzip utility will assume
     that a file is a text file if no non-ASCII characters are
     present within the first block of data decompressed for that
     file.  If non-ASCII characters appear in subsequent blocks of
     data, a warning will be issued.
https://www.freebsd.org/cgi/man.cgi?query=unzip&sektion=1&manpath=FreeBSD+10.3-RELEASE
Show 6 quoted lines
> Heh.  It was created like so:
> 
> 	$ printf 'text\r\n' >text && zip -ll infozip-text.zip text
> 	$ zipinfo infozip-text.zip text
>         -rw-r-----  3.0 unx        5 tx stor 16-Jul-18 13:12 text
> 

Thanks, but I think the test file is too small. I tried setting up a test to store the text file as binary in the zip to check for inadvertant CRLF conversions:

  printf 'text\r\n' >binary && zip -B infozip-binary.zip binary
But zip -B/--binary only works on VM/CMS and MVS...
So I'm inclined to go with Dscho's patch.
(apologies for messing up René's name in my previous email;
 on my new FreeBSD setup: mutt displays it fine, as does vim when
 taking it from .mailmap, but something gets lost when mutt
 populates the file for vim.  Perhaps some Debian patch didn't
 make it upstream...)
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 14 in “test-lib: stricter unzip(1) check”
  1. test-lib: stricter unzip(1) checkEric Wong, Jul 18, 2016
  2. Jeff KingJul 18, 2016
  3. Johannes SchindelinJul 18, 2016
  4. Junio C HamanoJul 18, 2016
  5. Jeff KingJul 18, 2016
  6. Junio C HamanoJul 18, 2016
  7. Johannes SchindelinJul 19, 2016
  8. Junio C HamanoJul 19, 2016
  9. Junio C HamanoJul 18, 2016
  10. Eric WongJul 18, 2016
  11. Junio C HamanoJul 18, 2016
  12. Eric WongJul 18, 2016
  13. Junio C HamanoJul 18, 2016
  14. Jeff KingJul 18, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.