GNU bug report logs - #62815
Gnus: MIME types of attachments contain regexp quotation

Previous Next

Package: emacs;

Reported by: Torsten Bronger <bronger <at> physik.rwth-aachen.de>

Date: Thu, 13 Apr 2023 11:52:02 UTC

Severity: normal

Fixed in version 29.1

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Andrew Cohen <cohen <at> bu.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 62815 <at> debbugs.gnu.org, Arash Esbati <arash <at> gnu.org>, Andreas Schwab <schwab <at> linux-m68k.org>, bronger <at> physik.rwth-aachen.de, larsi <at> gnus.org, Andrew G Cohen <cohen <at> andy.bu.edu>
Subject: bug#62815: Gnus: MIME types of attachments contain regexp quotation
Date: Sun, 23 Apr 2023 10:43:27 +0800
>>>>> "EZ" == Eli Zaretskii <eliz <at> gnu.org> writes:

    EZ> Andrew, perhaps you could look into this some time soon?  It
    EZ> sounds like a recent regression, so I'd like to fix this in
    EZ> Emacs 29.

(I've added Arash Esbati who filed the original bug that this commit was
intended to fix, and Andreas since I think he understands mime handling
in gnus and can probably comment.)

I have taken a quick look and think I understand what is going on, but
I'm not positive. The mailcap-mime-data can include a regexp for the
subtype; it appears that the only circumstance in which it is used as a
regexp is matching the possible viewer to be used for this subtype.

The patch in commit 3faa508eba84a1983732099cbd3cc1eaad404158 also treats
mailcap-mime-extensions as regexps, which I think is a mistake: these
should be associations between mime types and file extensions.

If all this is right, the simple fix is to revert the part of
3faa508eba84a1983732099cbd3cc1eaad404158 that treated the extension data
as regexps.  I have attached a diff below that does this. If Torsten
and Arash can check if this continues to provide a fix for bug#52038 and
bug#62815 that would be great!

There is one more place I think needs fixing (and maybe others I haven't
spotted yet):  the function mailcap-mime-types returns a list of mime
types, and excludes any type that contains a wildcard:
(unless (string-search "*" type) (push type res))
which suggests that this should be a list of actual types and not
include regexps. Hence we should remove any regexp quoting from the
entries. I have included a line that removes the "\\" in the diff.

diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el
index 10c5a7744c1..b8990266069 100644
--- a/lisp/net/mailcap.el
+++ b/lisp/net/mailcap.el
@@ -979,7 +979,7 @@ mailcap-mime-extensions
     (".vox"   . "audio/basic")
     (".vrml"  . "x-world/x-vrml")
     (".wav"   . "audio/x-wav")
-    (".xls"   . "application/vnd\\.ms-excel")
+    (".xls"   . "application/vnd.ms-excel")
     (".wrl"   . "x-world/x-vrml")
     (".xbm"   . "image/xbm")
     (".xpm"   . "image/xpm")
@@ -1051,8 +1051,7 @@ mailcap-parse-mimetype-file
 	(setq save-pos (point))
 	(skip-chars-forward "^ \t\n")
 	(downcase-region save-pos (point))
-	(setq type (mailcap--regexp-quote-type
-                    (buffer-substring save-pos (point))))
+	(setq type (buffer-substring save-pos (point)))
 	(while (not (eolp))
 	  (skip-chars-forward " \t")
 	  (setq save-pos (point))
@@ -1107,7 +1106,7 @@ mailcap-mime-types
         (dolist (info (cdr data))
           (setq type (cdr (assq 'type (cdr info))))
           (unless (string-search "*" type)
-            (push type res))))
+            (push (string-replace "\\" "" type) res))))
       (nreverse res)))))
 
 ;;;

-- 
Andrew Cohen




This bug report was last modified 1 year and 252 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.