From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#67002: 30.0.50; gnus-article-browse-html-save-cid-content could handle duplicate filenames better Date: Mon, 27 Nov 2023 08:43:59 -0800 Message-ID: <875y1np2nk.fsf@ericabrahamsen.net> References: <87h6lw1737.fsf@djcbsoftware.nl> <83wmufmnfo.fsf@gnu.org> <87ttpho6q3.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17064"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 67002@debbugs.gnu.org, "Dirk-Jan C. Binnema" , Andrew G Cohen To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 27 17:45:18 2023 Return-path: 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 ) id 1r7ejW-000481-3W for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 Nov 2023 17:45:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7ejB-0005ZW-SQ; Mon, 27 Nov 2023 11:44:57 -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 ) id 1r7ejA-0005Z6-9i for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2023 11:44:56 -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 ) id 1r7ejA-0000Px-1E for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2023 11:44:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r7ejG-000505-3u for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2023 11:45:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Nov 2023 16:45:02 +0000 Resent-Message-ID: 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.170110345819146 (code B ref 67002); Mon, 27 Nov 2023 16:45:02 +0000 Original-Received: (at 67002) by debbugs.gnu.org; 27 Nov 2023 16:44:18 +0000 Original-Received: from localhost ([127.0.0.1]:44655 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7eiX-0004yk-Ft for submit@debbugs.gnu.org; Mon, 27 Nov 2023 11:44:17 -0500 Original-Received: from mail.ericabrahamsen.net ([52.70.2.18]:53258) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7eiU-0004yR-H8 for 67002@debbugs.gnu.org; Mon, 27 Nov 2023 11:44:15 -0500 Original-Received: from localhost (71-212-21-65.tukw.qwest.net [71.212.21.65]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 2D06EFA01F; Mon, 27 Nov 2023 16:44:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1701103441; bh=WJCE7tQkvKtjepsCfbR+doV9UC1QKaw2CKuMpU34vNo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=YDKtbSCWdqtpyfTDCKdAYha5HiCxtiLam7HvEL5neA8RrBDweDL1w5A4iTL341i8X K53Kk6Vqy+QB5Y1koCTdtssCqSdZn1P+58gxuwn++9H1os8NgO4QL2eStFAqoP42Pm wz6dAEaMjaCesxamTLcJwYFuuPKY/iLfETQxylnU= In-Reply-To: <87ttpho6q3.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Sun, 19 Nov 2023 11:58:44 -0800") 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" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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:275137 Archived-At: Eric Abrahamsen writes: > Eli Zaretskii writes: > >>> From: "Dirk-Jan C. Binnema" >>> 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. I got around to looking at this, and I'd misunderstood what was happening here -- it's kind of a non-interactive context, where the user is only expecting to view the end result. So I think this is a fine solution. I'll poke at it a bit more, and close this bug report when the fix goes in. Thanks! Eric