GNU bug report logs - #5475
Archives with filenames with square brackets

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> jurta.org>

Date: Mon, 25 Jan 2010 17:58:02 UTC

Severity: normal

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 5475 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Chong Yidong <cyd <at> stupidchicken.com>
Cc: juri <at> jurta.org, 5475 <at> debbugs.gnu.org
Subject: Re: bug#5475: Archives with filenames with square brackets
Date: Tue, 26 Jan 2010 23:47:37 +0200
> From: Chong Yidong <cyd <at> stupidchicken.com>
> Date: Tue, 26 Jan 2010 16:05:20 -0500
> Cc: 5475 <at> debbugs.gnu.org
> 
> > When a zip archive contains a file with square brackets in its name
> > (e.g. "file[name].txt") then visiting this file displays an error:
> >
> >   caution: filename not matched:  file[name].txt
> 
> I assume this is a specific quirk of unzip that it handles square
> brackets specially (characters like * seem to be handled literally).

I think it treats all wildcard characters the same.  A `*' may not
cause a warning because a file whose name is literally foo*, matches
the wildcard foo*.

> How about this patch?
> 
> *** lisp/arc-mode.el	2010-01-13 08:35:10 +0000
> --- lisp/arc-mode.el	2010-01-26 21:03:54 +0000
> ***************
> *** 1782,1787 ****
> --- 1782,1791 ----
>       (apply 'vector (nreverse files))))
>   
>   (defun archive-zip-extract (archive name)
> +   (when (string-match "[][]" name)
> +     (require 'comint)
> +     (let ((comint-file-name-quote-list '(?\] ?\[)))
> +       (setq name (comint-quote-filename name))))
>     (if (equal (car archive-zip-extract) "pkzip")
>         (archive-*-extract archive name archive-zip-extract)
>       (archive-extract-by-stdout archive name archive-zip-extract)))

First, why not use shell-quote-argument, instead of requiring comint?

Second, could someone please see if pkzip also expands wildcards
internally?  If it does not, the quoting will need to be done only in
the non-pkzip branch.  We also need to test this on MS-Windows.

But most importantly, this patch is not clean, IMO: it hardcodes into
archive-zip-extract (the function) some knowledge of what can be the
possible values of archive-zip-extract the defcustom.  What if
tomorrow there will be a 3rd possibility, in addition to pkzip and
unzip?

That is why I thought about some less trivial patch: add to the data
structures that are values of these defcustom's a flag to indicate
whether the file name needs to be quoted or not.




This bug report was last modified 15 years and 37 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.