From unknown Tue Jun 17 01:34:46 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#65224 <65224@debbugs.gnu.org> To: bug#65224 <65224@debbugs.gnu.org> Subject: Status: =?UTF-8?Q?mailcap-viewer-passes-test=E2=80=99s?= caching interferes with precomputed tests Reply-To: bug#65224 <65224@debbugs.gnu.org> Date: Tue, 17 Jun 2025 08:34:46 +0000 retitle 65224 mailcap-viewer-passes-test=E2=80=99s caching interferes with = precomputed tests reassign 65224 emacs submitter 65224 Felix Dietrich severity 65224 normal tag 65224 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 11 06:49:28 2023 Received: (at submit) by debbugs.gnu.org; 11 Aug 2023 10:49:28 +0000 Received: from localhost ([127.0.0.1]:45018 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qUPhv-0000Vt-V0 for submit@debbugs.gnu.org; Fri, 11 Aug 2023 06:49:28 -0400 Received: from lists.gnu.org ([2001:470:142::17]:46644) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qUPhu-0000Vg-4L for submit@debbugs.gnu.org; Fri, 11 Aug 2023 06:49:27 -0400 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 1qUPhm-0002na-FU for bug-gnu-emacs@gnu.org; Fri, 11 Aug 2023 06:49:18 -0400 Received: from mout.kundenserver.de ([212.227.126.134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qUPhk-0003GI-E6 for bug-gnu-emacs@gnu.org; Fri, 11 Aug 2023 06:49:18 -0400 Received: from localhost ([77.191.1.9]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MofLl-1q2Fsm06m1-00p7Uv for ; Fri, 11 Aug 2023 12:49:13 +0200 From: Felix Dietrich To: bug-gnu-emacs Subject: =?utf-8?Q?mailcap-viewer-passes-test=E2=80=99s?= caching interferes with precomputed tests Date: Fri, 11 Aug 2023 12:48:49 +0200 Message-ID: <877cq1rh0u.fsf@sperrhaken.name> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Provags-ID: V03:K1:WN9/Lq3NGGvCayJ64JDROes+sqod6rM9d4U541RJipN72rZ5m3d 1Gq8xuSI5LoJW9G+OWa+6BDEH92KRitAliawp7HgAzzsZaAfXaxutKm9DJqV+VK2XJVYtdd lUsnKODu5ckRBKupjQ/RKDZgxK7BJI251x6nyR/fJ++gFh82FNKJRCKNwGs/F9/H5eav1Dx DVUpJ5h5chjn/642mocXg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:ErsviZDKWCI=;AKfVDQml0LS7fPCJDHwnCIBcoaJ sOybWd+7i4MFf23F750lmFu4vLT0O33ioChgbNL2+mPYbCUxsxNa5WcR5683nGjgKubfUZVf+ i2eh1+7Ap36MThuV/XO2H5g4Ug5Maltc4HDS5EgkbwnqG2flaOoS1jWKpT+q8QtIxIsD+3J3h P/xzM1fCegJC7uTJdyK4ChEicGg/ripiPtB5hvxiYMBKlXKeclxht2mILvKqOuq9VIvU8Cmfs MJ6+hcAI5D+FlCf8C2+N7jEgjUP0jUBo/ji5vCAzoTWDpIKdlQszorww54SrHExZ3OEU5XjpV aI+PP+XBVUmLNWcRr8s+690LCncLLms+SUDmopZGPmghy6jFkLNyZ+DNcrOU3LcY0tCeQOjYJ PTGVtK7Bh0UjqdpfYFKYu+0tK6R9a9EJSBHvHr5vPdLb/Hd8AfKyZmvEz+TWlic+DP03yi9FW MrRo2qhvKzIo0z03zH879z1uAataW1am12RHizQiT60aDkjpYj6EaQFpf/s9MsLX3jOuY/iye lbT7+YJqgXlmTV7CDSTT1gButbUMzGyshOscEfComTY9XMB7AgjZrIfmstqnM/wWRGrW0uVr/ tMb+8S0CBq2M02TCacJGENSpM7yEhBfP8kca/QKOd9hWk1ZMHmYsS0bVaokld6JhXDA67JjKf gEuhb1kVjr39s3pCHzyzvJNEcV4W50c2rPHxQFGnKXegwMdjT+0z18pelnqfrxPVMjWi7izuv mdpRcl6F81Jk5tWtBgM93988eaDId9/b2wgCmHnfgXLlIMI2jG2m9HK/2fwrht/ow5PPnFyo9 d2zzKRB6PlV+gjlAhExV4ScQkDMN2mPYWhKmnjW9nxGpSmjLlxmm2fbEfOgDgiMPDzt23Opwc 2dEFfQR4c8461NQ== Received-SPF: pass client-ip=212.227.126.134; envelope-from=felix.dietrich@sperrhaken.name; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable When called with a VIEWER-INFO that does not contain a test, =E2=80=98mailcap-viewer-passes-test=E2=80=99 erroneously returns nil if it = had previously been called with a VIEWER-INFO whose test was explicitly set to nil. As a consequence =E2=80=98mailcap-mime-info=E2=80=99 (used e.g. by =E2=80=98gnus-mime-view-part-externally=E2=80=99) may return the wrong view= er. The reason is that =E2=80=98mailcap-viewer-passes-test=E2=80=99 adds tests = that are explicitly nil (i.e. (test . nil)) to the cache as (nil nil) (first the test, second the result) and checks for the non-existence of a test only after it has tried to find the test result in the cache. The test variable for a VIEWER-INFO without a test is nil, and, therefore, the assoc lookup for nil done on the cache yields (nil nil) and, hence, nil (the cadr) as the test result. Moving the check for the non-existence of a test before the cache lookup fixes the issue; this is what the attached patch does. In the log message the bug number (Bug#) needs to be filled in. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Make-mailcap-viewer-passes-test-return-t-for-viewers.patch Content-Transfer-Encoding: quoted-printable Content-Description: Patch with fix and test >From 811ef5f697e165c58c54b3839672c920336da947 Mon Sep 17 00:00:00 2001 From: Felix Dietrich Date: Sun, 6 Aug 2023 06:01:24 +0200 Subject: [PATCH] =3D?UTF-8?q?Make=3D20=3DE2=3D80=3D98mailcap-viewer-passes-= test?=3D =3D?UTF-8?q?=3DE2=3D80=3D99=3D20return=3D20t=3D20for=3D20viewers=3D20witho= ut=3D20tests?=3D MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * lisp/net/mailcap.el (mailcap-viewer-passes-test): Make =E2=80=98mailcap-viewer-passes-test=E2=80=99 follow its docstring and = return t for viewers without a test. (Bug#) * test/lisp/net/mailcap-tests.el (mailcap-viewer-passes-test-w/o-test-returns-t): New test. --- lisp/net/mailcap.el | 2 +- test/lisp/net/mailcap-tests.el | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el index 4d01737e3e6..81cc51f1bf0 100644 --- a/lisp/net/mailcap.el +++ b/lisp/net/mailcap.el @@ -689,9 +689,9 @@ to supply to the test." status cache result) (cond ((not (or (stringp viewer) (fboundp viewer))) nil) ; Non-existent Lisp function + ((null test-info) t) ; No test clause ((setq cache (assoc test mailcap-viewer-test-cache)) (cadr cache)) - ((not test-info) t) ; No test clause (t (setq result diff --git a/test/lisp/net/mailcap-tests.el b/test/lisp/net/mailcap-tests.el index e47ead98f42..fa72d1bd285 100644 --- a/test/lisp/net/mailcap-tests.el +++ b/test/lisp/net/mailcap-tests.el @@ -537,5 +537,30 @@ help to verify the correct addition and merging of an = entry." ("minor" . ((viewer . "viewer") (edit . "edit"))))))))) =20 + + +(ert-deftest mailcap-viewer-passes-test-w/o-test-returns-t () + "A VIEWER-INFO without a test should return t with a valid viewer." + + (should (equal t + (let ((mailcap-viewer-test-cache) + (viewer-info + (list (cons 'viewer "viewer-w/o-test")))) + (mailcap-viewer-passes-test viewer-info nil)))) + + (should (equal '(t t nil t) + (let ((mailcap-viewer-test-cache) + (viewer-infos + (list + (list (cons 'viewer "viewer-w/o-test")) + (list (cons 'viewer "viewer-w/o-test")) + (list (cons 'viewer "viewer-w/nil-test") + (cons 'test nil)) + (list (cons 'viewer "viewer-w/o-test")) + ))) + (mapcar (lambda (vi) + (mailcap-viewer-passes-test vi nil)) + viewer-infos))))) + =20 ;;; mailcap-tests.el ends here --=20 2.40.1 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable The following example calls =E2=80=98mailcap-viewer-passes-test=E2=80=99 fo= ur times. For the first, second and third call the VIEWER-INFO does not contain a test; for the third the test is nil. The results show that the first and second call correctly return t; the third with (test . nil) correctly returns nil and adds (nil nil) to the cache; the fourth, then, incorrectly returns nil. #+HEADER: :results table #+begin_src emacs-lisp (let (mailcap-viewer-test-cache (viewer-infos (list (list (cons 'viewer "viewer-w/o-test")) (list (cons 'viewer "viewer-w/o-test")) (list (cons 'viewer "viewer-w/-test-nil") (cons 'test nil)) (list (cons 'viewer "viewer-w/o-test"))))) (cl-list* (list "Index" "Viewer" "Passes Test" "Cache after Call") 'hline (cl-loop for i =3D 1 then (1+ i) for vi in viewer-infos collect (list (format "%i." i) (alist-get 'viewer vi) (mailcap-viewer-passes-test vi ni= l) mailcap-viewer-test-cache)))) #+end_src #+RESULTS: | Index | Viewer | Passes Test | Cache after Call | |-------+--------------------+-------------+------------------| | 1. | viewer-w/o-test | t | nil | | 2. | viewer-w/o-test | t | nil | | 3. | viewer-w/-test-nil | nil | ((nil nil)) | | 4. | viewer-w/o-test | nil | ((nil nil)) | --=20 Felix Dietrich --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 12:52:37 2023 Received: (at control) by debbugs.gnu.org; 8 Sep 2023 16:52:37 +0000 Received: from localhost ([127.0.0.1]:45420 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeeij-00026t-8p for submit@debbugs.gnu.org; Fri, 08 Sep 2023 12:52:37 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:59648) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeeih-00026b-1I for control@debbugs.gnu.org; Fri, 08 Sep 2023 12:52:36 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-500b66f8b27so3900967e87.3 for ; Fri, 08 Sep 2023 09:52:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694191945; x=1694796745; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=HwoMubtV4H788CHAtFh4LGVcR5wAAiJfH8nPObGjm78=; b=P51ID797GRWAEhugbH55rKIU3ebOlToj+mGCto3NFGcWs61ML+iuB6K+ajxJBk2nfi VGg6EjakZAiGhAIxmS+yZliVvmxR7Fyq3zWdTThFoVJjXKA1EO/WysGf3f05U2kGSlCn LETLZSQCJ86UEpdb55A0Wxl/jgIk76FXxaDpSkcoFnisZqX731Id9k3DgPjbS3NxCduW CJb0+uAc40N0DZ+MjkVGFoqTM90CF5Idug+SuE9uDn/Sex7PS7G4kgM7A81RdSo1ADt+ Pc7eKMuNgS6t2oE4gm2dB+Kv97E01yc+nqsOZdgCFdjCHEu9v8lN1ef8xuERYfXK/1vs FnWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694191945; x=1694796745; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=HwoMubtV4H788CHAtFh4LGVcR5wAAiJfH8nPObGjm78=; b=KzU8Bc8sguxaE89VeQNVlxVJGi6NTczaC979cCkOKpoHB/JArIkkq/4Yh7UXdXEHro 7t6a8O8/DHRsD00h9F5ZSMDgwoPDiUm5ugYB1+4xR35vLgUcW9ngw30QeAjYT8Cu2fV4 M1TSCKiiPGR7iO28LB+RcdUx9ZWzpJHljDWz4ZZReSsCHBUQoDbU12CZmlkveglaJ/a/ k9nAYseYXyMgA94JegBTGXCyyzSCM/xkIEZduT6ElOIdsoJVfJtVMj/4J+Z7XtbhkbWQ 1Fnub63GwaQslKs15uCQX1vpCVifcLZ0P/EnGdHp3bhFx3sAfv2XsNgzcbu28yqNMxT2 POkQ== X-Gm-Message-State: AOJu0YzwgqavOgFFJ+JruVe8IVXpIkL8QLQB2u32G/WWs7ZAo70GiaDA FxPKdhbrAli0rTZWjcNGiRZZZnRjQLpk/MdU5J+UR6ki X-Google-Smtp-Source: AGHT+IGX1IU60+rbXsOZTlo1G3dmkoWLqkVuQxyrvSP6ueE/TYdyqahrjZvbz2U2wb7R3EU6PWWAgDRNhh+W/+b+QSQ= X-Received: by 2002:ac2:4841:0:b0:500:8146:9ebc with SMTP id 1-20020ac24841000000b0050081469ebcmr2130589lfy.47.1694191945407; Fri, 08 Sep 2023 09:52:25 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 8 Sep 2023 09:52:25 -0700 From: Stefan Kangas MIME-Version: 1.0 Date: Fri, 8 Sep 2023 09:52:25 -0700 Message-ID: Subject: control message for bug #65224 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 65224 + patch quit From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 13:21:04 2023 Received: (at 65224-done) by debbugs.gnu.org; 8 Sep 2023 17:21:04 +0000 Received: from localhost ([127.0.0.1]:45482 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qefAF-0005Za-Vz for submit@debbugs.gnu.org; Fri, 08 Sep 2023 13:21:04 -0400 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]:60512) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qefAD-0005Yz-CB for 65224-done@debbugs.gnu.org; Fri, 08 Sep 2023 13:21:02 -0400 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2bf5bf33bcdso32072591fa.0 for <65224-done@debbugs.gnu.org>; Fri, 08 Sep 2023 10:20:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694193653; x=1694798453; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:from:to:cc:subject:date :message-id:reply-to; bh=CanRxbXOp+XD8NoASDaq1NOOjcagURJtIhZ9N3qhXFc=; b=iaEL9aUY/wvkHyUAcu90MTbXxM9QEHu9I4UADWqF/w2KL8zJ0iGSMeb7jaNplkYCpo OqBYIdbogb58OTVC2pR2oU+Ble4Er6ibPqim/gAWLEw2IFcMgzeW7wbuTYc7L4CPpTG7 ptdNb0T28J9emiNfFNZSbATN/FlmVLnMPvU1madrd9YQsH0M445rdAqB7VnwnJ9D66p9 LRy18/YF6mkWy2y0rXRovqW7xTPSl/GTo+JLQ8nv7uAFzBRm3Zv8hrjmhqmS+XAXh4SM sYr1wbhdeMfzaSN/kM85KWL9U54GFxenWM6EkfgSOxN4WgGDBQQwyBZjVQkuDmv5A31v aErg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694193653; x=1694798453; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=CanRxbXOp+XD8NoASDaq1NOOjcagURJtIhZ9N3qhXFc=; b=jeH59GFtXCiqayJq+fG0FONkpjndGedv5yLknoj8eRu/KDR8h6y1baBb0lLTZ0pELw f54dE0rOYw5rrJG4PnnCP6dvbp5SnQhOD7D5BC40CUJ1fZev52zsg3eMHWtxfC8A39pi Q+zCIMAFsXMvKSUsSXkYm34/+ZuZ3XbNW0xXh4nxJ3gfJ5t1gCacHZX5L90AMC62t+16 0peu3CKQFoAXtChCMmCWmaZvyD3fkRhCfOPo1fykiLn6l7yROM9pH94KruSkgG/NkEQd JRLl7fqdcxPPBEo9+7XEtDXZGIRZ8e7SBLos+CpeAhgKLfXd2j+7MeoxS2k1Op4Qj+jp PHEw== X-Gm-Message-State: AOJu0YxIK1ufsypALkq72yQz/20LBkI02moRlDAFi7wg7srAQSoeupwd zWXs27UalFqDO1iEHi+rVHIZ4c/su4noa8BdnSg= X-Google-Smtp-Source: AGHT+IHeAsCXbhJqSmf6rxT6OS1i3ATuBc+8ZAd5KUWBDydhW4xbhZTozgqdK/J/yIHjVnBUeofDBXXZ0cvBuYrlbEw= X-Received: by 2002:a05:651c:203:b0:2bc:f439:b5a5 with SMTP id y3-20020a05651c020300b002bcf439b5a5mr2371584ljn.14.1694193652790; Fri, 08 Sep 2023 10:20:52 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 8 Sep 2023 10:20:52 -0700 From: Stefan Kangas In-Reply-To: <877cq1rh0u.fsf@sperrhaken.name> (Felix Dietrich's message of "Fri, 11 Aug 2023 12:48:49 +0200") References: <877cq1rh0u.fsf@sperrhaken.name> MIME-Version: 1.0 Date: Fri, 8 Sep 2023 10:20:52 -0700 Message-ID: Subject: =?UTF-8?Q?Re=3A_bug=2365224=3A_mailcap=2Dviewer=2Dpasses=2Dtest=E2=80=99s_cachin?= =?UTF-8?Q?g_interferes_with_precomputed_tests?= To: Felix Dietrich Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 65224-done Cc: 65224-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Version: 30.1 Felix Dietrich writes: > When called with a VIEWER-INFO that does not contain a test, > =E2=80=98mailcap-viewer-passes-test=E2=80=99 erroneously returns nil if i= t had > previously been called with a VIEWER-INFO whose test was explicitly set > to nil. As a consequence =E2=80=98mailcap-mime-info=E2=80=99 (used e.g. = by > =E2=80=98gnus-mime-view-part-externally=E2=80=99) may return the wrong vi= ewer. > > The reason is that =E2=80=98mailcap-viewer-passes-test=E2=80=99 adds test= s that are > explicitly nil (i.e. (test . nil)) to the cache as (nil nil) (first the > test, second the result) and checks for the non-existence of a test only > after it has tried to find the test result in the cache. The test > variable for a VIEWER-INFO without a test is nil, and, therefore, the > assoc lookup for nil done on the cache yields (nil nil) and, hence, nil > (the cadr) as the test result. > > Moving the check for the non-existence of a test before the cache lookup > fixes the issue; this is what the attached patch does. In the log > message the bug number (Bug#) needs to be filled in. LGTM, pushed to master as commit 6d8458571f7. From unknown Tue Jun 17 01:34:46 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 07 Oct 2023 11:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator