unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrew Cohen <cohen@bu.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 62815@debbugs.gnu.org, Arash Esbati <arash@gnu.org>,
	Andreas Schwab <schwab@linux-m68k.org>,
	bronger@physik.rwth-aachen.de, larsi@gnus.org,
	Andrew G Cohen <cohen@andy.bu.edu>
Subject: bug#62815: Gnus: MIME types of attachments contain regexp quotation
Date: Sun, 23 Apr 2023 10:43:27 +0800	[thread overview]
Message-ID: <87bkjf8gj4.fsf@ust.hk> (raw)
In-Reply-To: <831qkc2tq2.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 22 Apr 2023 11:42:45 +0300")

>>>>> "EZ" == Eli Zaretskii <eliz@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





  reply	other threads:[~2023-04-23  2:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13 11:46 bug#62815: Gnus: MIME types of attachments contain regexp quotation Torsten Bronger
2023-04-13 14:48 ` Eli Zaretskii
2023-04-22  8:42   ` Eli Zaretskii
2023-04-23  2:43     ` Andrew Cohen [this message]
2023-04-24 10:29       ` Arash Esbati
2023-04-30  1:26     ` Andrew Cohen
2023-05-07  0:21 ` Andrew Cohen
2023-05-07  5:17   ` Eli Zaretskii
2023-09-14  0:42     ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bkjf8gj4.fsf@ust.hk \
    --to=cohen@bu.edu \
    --cc=62815@debbugs.gnu.org \
    --cc=arash@gnu.org \
    --cc=bronger@physik.rwth-aachen.de \
    --cc=cohen@andy.bu.edu \
    --cc=eliz@gnu.org \
    --cc=larsi@gnus.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).