diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2022-10-01 15:20:42 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-10-01 15:20:42 +0200 |
commit | 3faa508eba84a1983732099cbd3cc1eaad404158 (patch) | |
tree | 5780ac10ed984e75ee901fe79d5933ca233c99de /lisp/net | |
parent | 41234a21bf7d6713491ce60501bbf2d211fbac8e (diff) | |
download | emacs-3faa508eba84a1983732099cbd3cc1eaad404158.tar.gz |
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.
Diffstat (limited to 'lisp/net')
-rw-r--r-- | lisp/net/mailcap.el | 11 |
1 files changed, 8 insertions, 3 deletions
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) |