emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e9a1dcbf773: Ensure CID filenames are unique when browsing Gnus a


From: Eric Abrahamsen
Subject: master e9a1dcbf773: Ensure CID filenames are unique when browsing Gnus article HTML
Date: Fri, 8 Dec 2023 12:51:39 -0500 (EST)

branch: master
commit e9a1dcbf773a93bee5e19a79bfe0f1595918917c
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>

    Ensure CID filenames are unique when browsing Gnus article HTML
    
    Bug#67002
    
    * lisp/gnus/gnus-art.el (gnus-article-browse-html-save-cid-content):
    It's possible that multiple CID parts will have the same filename,
    leading to temporary files clobbering one another during browsing.
    This ensures that the temporary filenames are unique.
---
 lisp/gnus/gnus-art.el | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index bd9a49eb6a5..b4abb3680cb 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -2871,12 +2871,15 @@ Return file name relative to the parent of DIRECTORY."
                              cid handle directory))
              (throw 'found file)))
           ((equal (concat "<" cid ">") (mm-handle-id handle))
-           (setq file (or (mm-handle-filename handle)
-                          (concat
-                           (make-temp-name "cid")
-                           (car (rassoc (car (mm-handle-type handle))
-                                        mailcap-mime-extensions))))
-                 afile (expand-file-name file directory))
+            ;; Randomize filenames: declared filenames may not be unique.
+            (setq file (format "cid-%d-%s"
+                              (random 99)
+                              (or (mm-handle-filename handle)
+                                  (concat
+                                   (make-temp-name "cid")
+                                   (car (rassoc (car (mm-handle-type handle))
+                                                mailcap-mime-extensions)))))
+                  afile (expand-file-name file directory))
            (mm-save-part-to-file handle afile)
            (throw 'found (concat (file-name-nondirectory
                                   (directory-file-name directory))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]