From 560696cc84d715f9623adf855d38b1768f1efcc5 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 7 May 2025 21:43:59 +0300 Subject: [PATCH] Improve support of UTF-8 encoded file names in ZIP archives * lisp/arc-mode.el (archive-zip-summarize): Support the 0x7075 UPath Unicode Path Extra Field extension of ZIP format. (Bug#78290) (cherry picked from commit 74e7e0f08abfe6b50ba7c2a153a989bf4910835e) --- lisp/arc-mode.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index 5c707576376..57293156a8a 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -2091,6 +2091,25 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." ;; an 8-byte uncompressed size. (archive-l-e (+ p 46 fnlen 4) 8) ucsize)) + (up-len (if (and (> exlen 9) ; 0x7075 Tag: 2 bytes, + ; TSize: 2 bytes, + ; Version: 1 byte, + ; CRC32: 4 bytes + ;; UPath extension tag 0x7075 ("up") + (eq (char-after (+ p 46 fnlen)) ?u) + (eq (char-after (+ p 46 fnlen 1)) ?p)) + ;; Subtract 1 byte for version and 4 more + ;; bytes for file-name's CRC-32 + (- (archive-l-e (+ p 46 fnlen 2) 2) 5))) + (upath (if up-len + ;; FIXME: Should verify UPath is up-to-date by + ;; computing CRC-32 and comparing with the + ;; value stored before UPath + (decode-coding-region (+ p 46 fnlen 9) + (+ p 46 fnlen 9 up-len) + 'utf-8-unix + t))) + (efnname (or upath efnname)) (isdir (and (= ucsize 0) (string= (file-name-nondirectory efnname) ""))) (mode (cond ((memq creator '(2 3)) ; Unix -- 2.39.5