bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#67002: 30.0.50; gnus-article-browse-html-save-cid-content could hand


From: Eric Abrahamsen
Subject: bug#67002: 30.0.50; gnus-article-browse-html-save-cid-content could handle duplicate filenames better
Date: Sun, 19 Nov 2023 11:58:44 -0800
User-agent: Gnus/5.13 (Gnus v5.13)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: "Dirk-Jan C. Binnema" <djcb@djcbsoftware.nl>
>> Date: Wed, 08 Nov 2023 19:35:24 +0200
>> 
>> Dear Gnus,
>> 
>> This came up in a mu4e bug:
>>   https://github.com/djcb/mu/issues/2460
>> 
>> (for reference: mu4e is /another/ Emacs MUA, which re-uses a lot of Gnus 
>> code)
>> 
>> Basically, in the attached html-email there are _two_ CIDs with the same
>> filename (but with different content-ids)
>> 
>> When doing a view-in-browser, gnus-article-browse-html-save-cid-content
>> uses the filename in favor of the cid, and the first file will be
>> overwritten by the second.
>> 
>> Admittedly, a corner-case. But, it can be fixed.
>> This fixes it for me:
>> 
>> --8<---------------cut here---------------start------------->8---
>> @@ -2871,11 +2871,14 @@ gnus-article-browse-html-save-cid-content
>>                            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))))
>> +        ;; Files are randomized since 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))
>> --8<---------------cut here---------------end--------------->8---
>
> Eric, Andrew: any comments?

We've already got machinery for this sort of thing, in `mm-save-part',
and `gnus-article-browse-html-save-cid-content' gives me the impression
that it predates the helper functions in "mm-decode.el". Give me a few
days, and I'll see if it can't be refactored onto mm-decode.

Thanks,
Eric





reply via email to

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