From: Eric Abrahamsen Date: Fri, 8 Dec 2023 17:48:51 +0000 (-0800) Subject: Ensure CID filenames are unique when browsing Gnus article HTML X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1365eaa3b0b006d676b7e576a55499a4d5dbeb9b;p=emacs.git 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. --- 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))