From 1365eaa3b0b006d676b7e576a55499a4d5dbeb9b Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Fri, 8 Dec 2023 09:48:51 -0800 Subject: [PATCH] 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)) -- 2.39.2