Subject: bug#78764: [PATCH] mailcap: Treat .ics files as text/calendar

From: Steven Allen <[email-masked]>
Date: Wed, 11 Jun 2025 15:01:45 -0700

Tags: patch

Add a mapping from ".ics" to "text/calendar" to mailcap-mime-extensions
to ensure that iCalendar attachments are always previewed correctly,
even when their MIME type is incorrect (as it is for Google Calendar invites).

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, cairo version
 1.18.4) of 2025-06-11 built on Laptop
Repository revision: 87244ef1661f9e9d7c08f65047551e8a34cd92b2
Repository branch: makepkg
Windowing system distributor 'The X.Org Foundation', version 11.0.12101016
System Description: Arch Linux

Configured using:
 'configure
 'CPPFLAGS=-I/run/user/1000/build/emacs-git/src/mps-git/build/include '
 'LDFLAGS=-L/run/user/1000/build/emacs-git/src/mps-git/build/lib -Wl,-O1
 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now
 -Wl,-z,pack-relative-relocs -flto=auto' --prefix=/usr --sysconfdir=/etc
 --libexecdir=/usr/lib --localstatedir=/var --mandir=/usr/share/man
 --with-gameuser=:games --with-modules --without-m17n-flt
 --without-selinux --without-pop --without-gconf --disable-gc-mark-trace
 --with-mps=yes --enable-link-time-optimization
 --with-native-compilation=yes --with-xinput2 --with-x-toolkit=no
 --without-toolkit-scroll-bars --without-xaw3d --without-gsettings
 --with-cairo-xcb --without-xft --with-sound=no --with-tree-sitter
 --without-gpm --without-compress-install
 '--program-transform-name=s/\([ec]tags\)/\1.emacs/'
 'CFLAGS=-march=native -mtune=native -O3 -pipe -fno-plt -fexceptions
 -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection -fomit-frame-pointer
 -fno-math-errno -fno-trapping-math -fno-math-errno -fno-trapping-math
 -flto=auto''

>From e77702cc5ce09b48ad978ced4832c56e0bc2b05a Mon Sep 17 00:00:00 2001
From: Steven Allen <[email-masked]>
Date: Wed, 11 Jun 2025 14:55:43 -0700
Subject: [PATCH] mailcap: Treat .ics files as text/calendar

This ensures iCalendar attachments are always displayed correctly (via
`gnus-icalendar-mm-inline'), even when they have an incorrect MIME
type (looking at you Google Calendar).

* lisp/net/mailcap.el (mailcap-mime-extensions): Add a mapping from ".ics"
to "text/calendar".
---
 lisp/net/mailcap.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el
index 7e69826160e..b80baab97d5 100644
--- a/lisp/net/mailcap.el
+++ b/lisp/net/mailcap.el
@@ -920,6 +920,7 @@ mailcap-mime-extensions
     (".htm"   . "text/html")
     (".html"  . "text/html")
     (".icon"  . "image/x-icon")
+    (".ics"   . "text/calendar")
     (".ief"   . "image/ief")
     (".jpg"   . "image/jpeg")
     (".macp"  . "image/x-macpaint")
-- 
2.49.0