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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 62815 in the body.
You can then email your comments to 62815 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#62815; Package emacs. (Thu, 13 Apr 2023 11:52:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Torsten Bronger <bronger <at> physik.rwth-aachen.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 13 Apr 2023 11:52:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Torsten Bronger <bronger <at> physik.rwth-aachen.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Gnus: MIME types of attachments contain regexp quotation
Date: Thu, 13 Apr 2023 13:46:38 +0200
Hallöchen!

Since commit 3faa508eba84a1983732099cbd3cc1eaad404158, I observe
incorrect MIME types in my outgoing mails, e.g.

…
--=-=-=
Content-Type: application/vnd\.oasis\.opendocument\.spreadsheet
Content-Disposition: attachment;
 filename=2022-12-15_Nachbestellung_Studio.ods
Content-Transfer-Encoding: base64
…


Reason is that when attaching a file to a mail in Gnus, the MIME
type is suggested by Gnus, and this suggestion contains the
incorrect backslashes.

Regards,
Torsten.

-- 
Torsten Bronger





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62815; Package emacs. (Thu, 13 Apr 2023 14:48:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Torsten Bronger <bronger <at> physik.rwth-aachen.de>,
 Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#62815: Gnus: MIME types of attachments contain regexp
 quotation
Date: Thu, 13 Apr 2023 17:48:22 +0300
> From: Torsten Bronger <bronger <at> physik.rwth-aachen.de>
> Date: Thu, 13 Apr 2023 13:46:38 +0200
> 
> Hallöchen!
> 
> Since commit 3faa508eba84a1983732099cbd3cc1eaad404158, I observe
> incorrect MIME types in my outgoing mails, e.g.
> 
> …
> --=-=-=
> Content-Type: application/vnd\.oasis\.opendocument\.spreadsheet
> Content-Disposition: attachment;
>  filename=2022-12-15_Nachbestellung_Studio.ods
> Content-Transfer-Encoding: base64
> …
> 
> 
> Reason is that when attaching a file to a mail in Gnus, the MIME
> type is suggested by Gnus, and this suggestion contains the
> incorrect backslashes.

Lars, could you please look into this?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62815; Package emacs. (Sat, 22 Apr 2023 08:43:01 GMT) Full text and rfc822 format available.

Message #11 received at 62815 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andrew G Cohen <cohen <at> andy.bu.edu>
Cc: 62815 <at> debbugs.gnu.org, larsi <at> gnus.org, bronger <at> physik.rwth-aachen.de
Subject: Re: bug#62815: Gnus: MIME types of attachments contain regexp
 quotation
Date: Sat, 22 Apr 2023 11:42:45 +0300
> Cc: 62815 <at> debbugs.gnu.org
> Date: Thu, 13 Apr 2023 17:48:22 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> 
> > From: Torsten Bronger <bronger <at> physik.rwth-aachen.de>
> > Date: Thu, 13 Apr 2023 13:46:38 +0200
> > 
> > Hallöchen!
> > 
> > Since commit 3faa508eba84a1983732099cbd3cc1eaad404158, I observe
> > incorrect MIME types in my outgoing mails, e.g.
> > 
> > …
> > --=-=-=
> > Content-Type: application/vnd\.oasis\.opendocument\.spreadsheet
> > Content-Disposition: attachment;
> >  filename=2022-12-15_Nachbestellung_Studio.ods
> > Content-Transfer-Encoding: base64
> > …
> > 
> > 
> > Reason is that when attaching a file to a mail in Gnus, the MIME
> > type is suggested by Gnus, and this suggestion contains the
> > incorrect backslashes.
> 
> Lars, could you please look into this?

Ping!

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62815; Package emacs. (Sun, 23 Apr 2023 02:44:01 GMT) Full text and rfc822 format available.

Message #14 received at 62815 <at> debbugs.gnu.org (full text, mbox):

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: Re: 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62815; Package emacs. (Mon, 24 Apr 2023 10:31:02 GMT) Full text and rfc822 format available.

Message #17 received at 62815 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Andrew Cohen <cohen <at> bu.edu>
Cc: Andrew G Cohen <cohen <at> andy.bu.edu>, 62815 <at> debbugs.gnu.org,
 Andreas Schwab <schwab <at> linux-m68k.org>, bronger <at> physik.rwth-aachen.de,
 larsi <at> gnus.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#62815: Gnus: MIME types of attachments contain regexp
 quotation
Date: Mon, 24 Apr 2023 12:29:38 +0200
Andrew Cohen <cohen <at> bu.edu> writes:

> 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!

Thanks for looking at this.  I built the latest repo version
(65735cee71) of Emacs and tried it with and w/o your patch.  It seems to
fix the issues Torsten and I have reported, but ...

> There is one more place I think needs fixing (and maybe others I haven't
> spotted yet):

I see a strange side effect when I use 'e' in article buffer to view a
attachment.  Without your change, Emacs starts Excel like this (this it
at least I see in *Messages* buffer) and it works:

  Displaying start excel.exe "`cygpath -w -a c\:/msys64/tmp/emm.fMzcnA/file_name.xlsx`"

With your change, I get:

  Displaying start excel.exe "`cygpath -w -a "c:/msys64/tmp/emm.QDUAFP/file_name.xlsx"`"

which doesn't work due to extra pair of quotes.  This is the entry in my
.mailcap:

  application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; \
                       start excel.exe "`cygpath -w -a %s`"

This on Win10.

Best, Arash




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62815; Package emacs. (Sun, 30 Apr 2023 01:27:02 GMT) Full text and rfc822 format available.

Message #20 received at 62815 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Cohen <cohen <at> bu.edu>
To: 62815 <at> debbugs.gnu.org
Cc: Eli Zaretskii <eliz <at> gnu.org>, Arash Esbati <arash <at> gnu.org>
Subject: Re: bug#62815: Gnus: MIME types of attachments contain regexp
 quotation
Date: Sun, 30 Apr 2023 09:26:13 +0800
Arash Esbati <arash <at> gnu.org> writes:
>Andrew Cohen <cohen <at> bu.edu> writes:

>> That is the odd part---the changes I made don't touch this at all.  This
>> is in the viewer part, and none of the changes should have any effect on
>> this part. 

>Hi Andy, sorry for the late response.  It took me longer since I went
>through a longer oddity show.  It turned out that your patch works, but
>I had to install Emacs into a directory, i.e., pass a directory to
>configure via --prefix.  Simply starting emacs.exe out of ./src
>directory throws the error I described in my other mail, very odd.  So
>from what I see, your change fixes both problems reported.  Maybe you
>install that change and others can test is as well.

Glad to hear that the patch seems to work. I'm not sure what is going on
with the installation on windows, but since it sounds like this is not
related to the current issue, I'll follow your suggestion and commit the
patch to master. Assuming no one reports a problem I think the patch can
then go to the 29 branch to fix the regression.

Best,
Andy

-- 
Andrew Cohen




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62815; Package emacs. (Sun, 07 May 2023 00:22:02 GMT) Full text and rfc822 format available.

Message #23 received at 62815 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Cohen <cohen <at> bu.edu>
To: 62815 <at> debbugs.gnu.org
Cc: Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#62815: Gnus: MIME types of attachments contain regexp
 quotation
Date: Sun, 07 May 2023 08:21:02 +0800
My patch has spent almost a week on master with no complaints. Eli, OK
to push this regression fix to emacs-29 and close the bug report?

(I assume to push to emacs-29 I just checkout emacs-29, cherry-pick the
commit, and push?)
-- 
Andrew Cohen




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62815; Package emacs. (Sun, 07 May 2023 05:18:01 GMT) Full text and rfc822 format available.

Message #26 received at 62815 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andrew Cohen <cohen <at> bu.edu>
Cc: 62815 <at> debbugs.gnu.org
Subject: Re: bug#62815: Gnus: MIME types of attachments contain regexp
 quotation
Date: Sun, 07 May 2023 08:17:50 +0300
> From: Andrew Cohen <cohen <at> bu.edu>
> Cc: Eli Zaretskii <eliz <at> gnu.org>
> Date: Sun, 07 May 2023 08:21:02 +0800
> 
> My patch has spent almost a week on master with no complaints. Eli, OK
> to push this regression fix to emacs-29 and close the bug report?
> 
> (I assume to push to emacs-29 I just checkout emacs-29, cherry-pick the
> commit, and push?)

Yes to both questions.

When you cherry-pick, be sure to use the -x switch to Git (or its
equivalent, if you don't invoke Git directly from the shell prompt),
so that the commit log message of the backport includes the telltale
"(cherry picked from commit ...)" line.




Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Thu, 14 Sep 2023 00:44:02 GMT) Full text and rfc822 format available.

Notification sent to Torsten Bronger <bronger <at> physik.rwth-aachen.de>:
bug acknowledged by developer. (Thu, 14 Sep 2023 00:44:02 GMT) Full text and rfc822 format available.

Message #31 received at 62815-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Andrew Cohen <cohen <at> bu.edu>, 62815-done <at> debbugs.gnu.org
Subject: Re: bug#62815: Gnus: MIME types of attachments contain regexp
 quotation
Date: Wed, 13 Sep 2023 17:42:47 -0700
Version: 29.1

Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Andrew Cohen <cohen <at> bu.edu>
>> Cc: Eli Zaretskii <eliz <at> gnu.org>
>> Date: Sun, 07 May 2023 08:21:02 +0800
>>
>> My patch has spent almost a week on master with no complaints. Eli, OK
>> to push this regression fix to emacs-29 and close the bug report?
>>
>> (I assume to push to emacs-29 I just checkout emacs-29, cherry-pick the
>> commit, and push?)
>
> Yes to both questions.
>
> When you cherry-pick, be sure to use the -x switch to Git (or its
> equivalent, if you don't invoke Git directly from the shell prompt),
> so that the commit log message of the backport includes the telltale
> "(cherry picked from commit ...)" line.

It seems like this issue was fixed, but it was left open in the bug
tracker.  I'm therefore closing it now.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 12 Oct 2023 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 191 days ago.

Previous Next


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