From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Eli Zaretskii <eliz@gnu.org>
Newsgroups: gmane.emacs.bugs
Subject: bug#67002: 30.0.50;
 gnus-article-browse-html-save-cid-content could handle duplicate
 filenames better
Date: Sat, 18 Nov 2023 11:16:11 +0200
Message-ID: <83wmufmnfo.fsf@gnu.org>
References: <87h6lw1737.fsf@djcbsoftware.nl>
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="24621"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: 67002@debbugs.gnu.org
To: "Dirk-Jan C. Binnema" <djcb@djcbsoftware.nl>,
 Eric Abrahamsen <eric@ericabrahamsen.net>, Andrew G Cohen <cohen@andy.bu.edu>
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 18 10:17:28 2023
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>
Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org
Original-Received: from lists.gnu.org ([209.51.188.17])
	by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
	(Exim 4.92)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1r4HSB-0006C6-Rp
	for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Nov 2023 10:17:27 +0100
Original-Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <bug-gnu-emacs-bounces@gnu.org>)
	id 1r4HRp-00029y-Ui; Sat, 18 Nov 2023 04:17:06 -0500
Original-Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1r4HRm-00027y-HN
 for bug-gnu-emacs@gnu.org; Sat, 18 Nov 2023 04:17:02 -0500
Original-Received: from debbugs.gnu.org ([2001:470:142:5::43])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1r4HRm-000317-7L
 for bug-gnu-emacs@gnu.org; Sat, 18 Nov 2023 04:17:02 -0500
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1r4HRm-0007QY-I6
 for bug-gnu-emacs@gnu.org; Sat, 18 Nov 2023 04:17:02 -0500
X-Loop: help-debbugs@gnu.org
Resent-From: Eli Zaretskii <eliz@gnu.org>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Sat, 18 Nov 2023 09:17:02 +0000
Resent-Message-ID: <handler.67002.B67002.170029898628499@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 67002
X-GNU-PR-Package: emacs
Original-Received: via spool by 67002-submit@debbugs.gnu.org id=B67002.170029898628499
 (code B ref 67002); Sat, 18 Nov 2023 09:17:02 +0000
Original-Received: (at 67002) by debbugs.gnu.org; 18 Nov 2023 09:16:26 +0000
Original-Received: from localhost ([127.0.0.1]:47797 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1r4HRC-0007Pb-Eo
 for submit@debbugs.gnu.org; Sat, 18 Nov 2023 04:16:26 -0500
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34662)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@gnu.org>) id 1r4HR7-0007PH-VE
 for 67002@debbugs.gnu.org; Sat, 18 Nov 2023 04:16:25 -0500
Original-Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@gnu.org>)
 id 1r4HQz-00014m-Te; Sat, 18 Nov 2023 04:16:13 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=HbIm7tzX4o67yOkWE+837pPkX8OTEyP1wUD/mV4o1wY=; b=qzys5cXsiD2o
 pg/YMX03px6svN0GOfPprg4k/S1xVNzl3SG/m8pjmlGBRJGC6EzfKazYTE1Y+sMVNi9cAu7lsZZf/
 caFqFNjDdUtm5Uc8kMQudsd9UBUo5uZRwHpoHQ5hz412tQhKeeHHrKdkrR3EHtQmu3E8Su4Qqyx65
 goymcqEfH5YIV7WC4e9W+3lzgbDMKqndad3/Olg1vMSgaVqSBe9v0qPwp/4LW+tX/FPwr6I/mrkNd
 j+kgO9onplyT7q+pLuzdzmUYjEPwF7jontdF88PDXyUMZbC8UZPCYip6nP5m6EaQbU/9cxXp7b7mu
 sbcfOkn3ywzzhGIKgZFc9A==;
In-Reply-To: <87h6lw1737.fsf@djcbsoftware.nl>
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
X-BeenThere: bug-gnu-emacs@gnu.org
List-Id: "Bug reports for GNU Emacs,
 the Swiss army knife of text editors" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-gnu-emacs>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Xref: news.gmane.io gmane.emacs.bugs:274539
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/274539>

> 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?