unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 67002@debbugs.gnu.org,
	"Dirk-Jan C. Binnema" <djcb@djcbsoftware.nl>,
	Andrew G Cohen <cohen@andy.bu.edu>
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	[thread overview]
Message-ID: <87ttpho6q3.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <83wmufmnfo.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 18 Nov 2023 11:16:11 +0200")

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	other threads:[~2023-11-19 19:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-08 17:35 bug#67002: 30.0.50; gnus-article-browse-html-save-cid-content could handle duplicate filenames better Dirk-Jan C. Binnema
2023-11-18  9:16 ` Eli Zaretskii
2023-11-19 19:58   ` Eric Abrahamsen [this message]
2023-11-27 16:43     ` Eric Abrahamsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ttpho6q3.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=67002@debbugs.gnu.org \
    --cc=cohen@andy.bu.edu \
    --cc=djcb@djcbsoftware.nl \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).