Subject: bug#5475: Archives with filenames with square brackets

From: Chong Yidong <[email-masked]>
Date: Tue, 26 Jan 2010 16:05:20 -0500

> 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).
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)))