From 714942b1c3767ee6c70a5644d6a4460dedbe4422 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 28 Dec 2023 16:51:45 +0200 Subject: [PATCH] Fix extraction of files with wildcards in names from zip archives * lisp/arc-mode.el (archive-zip-extract): Quote wildcard characters in file names as [C]. (Bug#67926) --- lisp/arc-mode.el | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index c861c835966..f54211e3320 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -2108,16 +2108,14 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." (t (archive-extract-by-stdout archive - ;; unzip expands wildcards in NAME, so we need to quote it. But - ;; not on DOS/Windows, since that fails extraction on those - ;; systems (unless w32-quote-process-args is nil), and file names - ;; with wildcards in zip archives don't work there anyway. - ;; FIXME: Does pkunzip need similar treatment? - (if (and (or (not (memq system-type '(windows-nt ms-dos))) - (and (boundp 'w32-quote-process-args) - (null w32-quote-process-args))) - (equal (car archive-zip-extract) "unzip")) - (shell-quote-argument name) + ;; unzip expands wildcard characters in NAME, so we need to quote + ;; wildcard characters in a special way: replace each such + ;; character C with a single-character alternative [C]. We + ;; cannot use 'shell-quote-argument' here because that doesn't + ;; protect wildcard characters from being expanded by unzip + ;; itself. + (if (equal (car archive-zip-extract) "unzip") + (replace-regexp-in-string "[[?*]" "[\\&]" name) name) archive-zip-extract)))) -- 2.39.5