]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve support of UTF-8 encoded file names in ZIP archives
authorEli Zaretskii <eliz@gnu.org>
Wed, 7 May 2025 18:43:59 +0000 (21:43 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sat, 10 May 2025 08:54:36 +0000 (10:54 +0200)
* 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

index 5c707576376db984cbeba37b1cad952cda9e0f81..57293156a8aa27c6b64dec044ff9d63239011a8e 100644 (file)
@@ -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