diff options
| author | Lars Ingebrigtsen | 2022-10-01 15:20:42 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-10-01 15:20:42 +0200 |
| commit | 3faa508eba84a1983732099cbd3cc1eaad404158 (patch) | |
| tree | 5780ac10ed984e75ee901fe79d5933ca233c99de | |
| parent | 41234a21bf7d6713491ce60501bbf2d211fbac8e (diff) | |
| download | emacs-3faa508eba84a1983732099cbd3cc1eaad404158.tar.gz emacs-3faa508eba84a1983732099cbd3cc1eaad404158.zip | |
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.
| -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." | |||
| 125 | ("vnd\\.ms-excel" | 125 | ("vnd\\.ms-excel" |
| 126 | (viewer . "gnumeric %s") | 126 | (viewer . "gnumeric %s") |
| 127 | (test . (getenv "DISPLAY")) | 127 | (test . (getenv "DISPLAY")) |
| 128 | (type . "application/vnd.ms-excel")) | 128 | (type . "application/vnd\\.ms-excel")) |
| 129 | ("octet-stream" | 129 | ("octet-stream" |
| 130 | (viewer . mailcap-save-binary-file) | 130 | (viewer . mailcap-save-binary-file) |
| 131 | (non-viewer . t) | 131 | (non-viewer . t) |
| @@ -979,7 +979,7 @@ If NO-DECODE is non-nil, don't decode STRING." | |||
| 979 | (".vox" . "audio/basic") | 979 | (".vox" . "audio/basic") |
| 980 | (".vrml" . "x-world/x-vrml") | 980 | (".vrml" . "x-world/x-vrml") |
| 981 | (".wav" . "audio/x-wav") | 981 | (".wav" . "audio/x-wav") |
| 982 | (".xls" . "application/vnd.ms-excel") | 982 | (".xls" . "application/vnd\\.ms-excel") |
| 983 | (".wrl" . "x-world/x-vrml") | 983 | (".wrl" . "x-world/x-vrml") |
| 984 | (".xbm" . "image/xbm") | 984 | (".xbm" . "image/xbm") |
| 985 | (".xpm" . "image/xpm") | 985 | (".xpm" . "image/xpm") |
| @@ -1051,7 +1051,8 @@ If FORCE, re-parse even if already parsed." | |||
| 1051 | (setq save-pos (point)) | 1051 | (setq save-pos (point)) |
| 1052 | (skip-chars-forward "^ \t\n") | 1052 | (skip-chars-forward "^ \t\n") |
| 1053 | (downcase-region save-pos (point)) | 1053 | (downcase-region save-pos (point)) |
| 1054 | (setq type (buffer-substring save-pos (point))) | 1054 | (setq type (mailcap--regexp-quote-type |
| 1055 | (buffer-substring save-pos (point)))) | ||
| 1055 | (while (not (eolp)) | 1056 | (while (not (eolp)) |
| 1056 | (skip-chars-forward " \t") | 1057 | (skip-chars-forward " \t") |
| 1057 | (setq save-pos (point)) | 1058 | (setq save-pos (point)) |
| @@ -1064,6 +1065,10 @@ If FORCE, re-parse even if already parsed." | |||
| 1064 | (setq mailcap-mime-extensions (append extns mailcap-mime-extensions) | 1065 | (setq mailcap-mime-extensions (append extns mailcap-mime-extensions) |
| 1065 | extns nil))))) | 1066 | extns nil))))) |
| 1066 | 1067 | ||
| 1068 | (defun mailcap--regexp-quote-type (type) | ||
| 1069 | (pcase-let ((`(,major ,minor) (split-string type "/"))) | ||
| 1070 | (concat major "/" (regexp-quote minor)))) | ||
| 1071 | |||
| 1067 | (defun mailcap-extension-to-mime (extn) | 1072 | (defun mailcap-extension-to-mime (extn) |
| 1068 | "Return the MIME content type of the file extensions EXTN." | 1073 | "Return the MIME content type of the file extensions EXTN." |
| 1069 | (mailcap-parse-mimetypes) | 1074 | (mailcap-parse-mimetypes) |