diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2021-01-10 19:47:22 +0100 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2021-01-15 07:30:33 -0400 |
| commit | 1f14dbfbd72d5c4aa04c4903155060f7c69c608f (patch) | |
| tree | 3fb6c92047ad11c34151eb156d14e8f6415cd755 /emacs/notmuch-lib.el | |
| parent | f1ae9addc6ca974393062c764518895af5f295c4 (diff) | |
emacs: avoid type errors due to nil as content-type
The output of "notmuch show --format=sexp --format-version=4"
may contain `:content-type' entries with `nil' as the value,
when it fails to detect the correct value. Account for that
in a few places where we would otherwise risk a type error.
Note that `string=' does not choke on `nil' because it uses
the `symbol-name' when encountering a symbol.
Diffstat (limited to 'emacs/notmuch-lib.el')
| -rw-r--r-- | emacs/notmuch-lib.el | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index bc550dc2..c7bb2091 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -552,16 +552,19 @@ This replaces spaces, percents, and double quotes in STR with ;;; MML Utilities (defun notmuch-match-content-type (t1 t2) - "Return t if t1 and t2 are matching content types, taking wildcards into account." - (let ((st1 (split-string t1 "/")) - (st2 (split-string t2 "/"))) - (if (or (string= (cadr st1) "*") - (string= (cadr st2) "*")) - ;; Comparison of content types should be case insensitive. - (string= (downcase (car st1)) - (downcase (car st2))) - (string= (downcase t1) - (downcase t2))))) + "Return t if t1 and t2 are matching content types. +Take wildcards into account." + (and (stringp t1) + (stringp t2) + (let ((st1 (split-string t1 "/")) + (st2 (split-string t2 "/"))) + (if (or (string= (cadr st1) "*") + (string= (cadr st2) "*")) + ;; Comparison of content types should be case insensitive. + (string= (downcase (car st1)) + (downcase (car st2))) + (string= (downcase t1) + (downcase t2)))))) (defvar notmuch-multipart/alternative-discouraged '(;; Avoid HTML parts. |
