From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen <eric@ericabrahamsen.net> Newsgroups: gmane.emacs.bugs 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 Message-ID: <87ttpho6q3.fsf@ericabrahamsen.net> References: <87h6lw1737.fsf@djcbsoftware.nl> <83wmufmnfo.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17140"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 67002@debbugs.gnu.org, "Dirk-Jan C. Binnema" <djcb@djcbsoftware.nl>, Andrew G Cohen <cohen@andy.bu.edu> To: Eli Zaretskii <eliz@gnu.org> Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 19 20:59:30 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 1r4nx4-0004Gz-Mp for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Nov 2023 20:59:30 +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 1r4nwd-0007Hj-R1; Sun, 19 Nov 2023 14:59:03 -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 1r4nwc-0007HE-BJ for bug-gnu-emacs@gnu.org; Sun, 19 Nov 2023 14:59: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 1r4nwb-00017u-TF for bug-gnu-emacs@gnu.org; Sun, 19 Nov 2023 14:59: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 1r4nwc-0002SN-FA for bug-gnu-emacs@gnu.org; Sun, 19 Nov 2023 14:59:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen <eric@ericabrahamsen.net> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Nov 2023 19:59:02 +0000 Resent-Message-ID: <handler.67002.B67002.17004239379412@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.17004239379412 (code B ref 67002); Sun, 19 Nov 2023 19:59:02 +0000 Original-Received: (at 67002) by debbugs.gnu.org; 19 Nov 2023 19:58:57 +0000 Original-Received: from localhost ([127.0.0.1]:52138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1r4nwW-0002Rj-GX for submit@debbugs.gnu.org; Sun, 19 Nov 2023 14:58:56 -0500 Original-Received: from mail.ericabrahamsen.net ([52.70.2.18]:41318) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eric@ericabrahamsen.net>) id 1r4nwU-0002RR-2a for 67002@debbugs.gnu.org; Sun, 19 Nov 2023 14:58:55 -0500 Original-Received: from localhost (50-245-141-81-static.hfc.comcastbusiness.net [50.245.141.81]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 534ECFA396; Sun, 19 Nov 2023 19:58:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1700423926; bh=uCf2rzEEa/fze0dSaO9KULfGSB+85vCk09jKAhjsErg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ASyf7+JiaocXdKTYfxXaI+fk6wp1D3yxnQa1UNnCQ0pkskwfE30TRejplzofd8UcJ ILFubVdrRoM9mmOjj2OfhD18oOJ4+mRziaQzkiGhP1oBTqwPeqwHZIrpyk0WSb3aUH k3OeuNLmksK3aYd88PVZhhXsQsItlshJLTrveZeI= In-Reply-To: <83wmufmnfo.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 18 Nov 2023 11:16:11 +0200") 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:274633 Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/274633> 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