From: Lars Ingebrigtsen Date: Sat, 1 Oct 2022 13:20:42 +0000 (+0200) Subject: Make mailcap consistent about regexp-quoting minors X-Git-Tag: emacs-29.0.90~1856^2~104 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3faa508eba84a1983732099cbd3cc1eaad404158;p=emacs.git Make mailcap consistent about regexp-quoting minors * lisp/net/mailcap.el (mailcap-mime-data): Quote regexp. (mailcap-mime-extensions): Ditto. (mailcap--regexp-quote-type): New function. (mailcap-parse-mimetype-file): Use it to get consistent quoting of (regexp) strings (bug#52038). Before you'd get both application/vnd\.ms-excel and application/vnd.ms-excel (etc), making prompting confusing. --- diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el index a5f589459b7..b678df30bd4 100644 --- a/lisp/net/mailcap.el +++ b/lisp/net/mailcap.el @@ -125,7 +125,7 @@ is consulted." ("vnd\\.ms-excel" (viewer . "gnumeric %s") (test . (getenv "DISPLAY")) - (type . "application/vnd.ms-excel")) + (type . "application/vnd\\.ms-excel")) ("octet-stream" (viewer . mailcap-save-binary-file) (non-viewer . t) @@ -979,7 +979,7 @@ If NO-DECODE is non-nil, don't decode STRING." (".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,7 +1051,8 @@ If FORCE, re-parse even if already parsed." (setq save-pos (point)) (skip-chars-forward "^ \t\n") (downcase-region save-pos (point)) - (setq type (buffer-substring save-pos (point))) + (setq type (mailcap--regexp-quote-type + (buffer-substring save-pos (point)))) (while (not (eolp)) (skip-chars-forward " \t") (setq save-pos (point)) @@ -1064,6 +1065,10 @@ If FORCE, re-parse even if already parsed." (setq mailcap-mime-extensions (append extns mailcap-mime-extensions) extns nil))))) +(defun mailcap--regexp-quote-type (type) + (pcase-let ((`(,major ,minor) (split-string type "/"))) + (concat major "/" (regexp-quote minor)))) + (defun mailcap-extension-to-mime (extn) "Return the MIME content type of the file extensions EXTN." (mailcap-parse-mimetypes)