[PATCH] Map missing content-type to "" instead of nil

2019-10-24 Thread keithp
From: Keith Packard 

When a message part has no content type, a 'nil' value results in many
failures when passed to functions like 'downcase'.  Instead of
crashing, map a nil value to the empty string, "", so that the show
operation doesn't crash.

Signed-off-by: Keith Packard 
---
 emacs/notmuch-show.el | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e13ca3d7..7e3d0501 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -556,6 +556,10 @@ message at DEPTH in the current thread."
   "Alist from raw content ID to (MSG PART).")
 (make-variable-buffer-local 'notmuch-show--cids)
 
+(defun notmuch-show--plist-get(l m)
+  (let ((e (plist-get l m)))
+(if e e "")))
+
 (defun notmuch-show--register-cids (msg part)
   "Register content-IDs in PART and all of PART's sub-parts."
   (let ((content-id (plist-get part :content-id)))
@@ -570,7 +574,7 @@ message at DEPTH in the current thread."
   (push (list content-id msg part) notmuch-show--cids)))
   ;; Recurse on sub-parts
   (let ((ctype (notmuch-split-content-type
-   (downcase (plist-get part :content-type)
+   (downcase (notmuch-show--plist-get part :content-type)
 (cond ((equal (first ctype) "multipart")
   (mapc (apply-partially #'notmuch-show--register-cids msg)
 (plist-get part :content)))
@@ -594,7 +598,7 @@ will return nil if the CID is unknown or cannot be 
retrieved."
 ;; reference the same cid: part many times (hundreds!).
 (content (notmuch-get-bodypart-binary
   msg part notmuch-show-process-crypto 'cache))
-(content-type (plist-get part :content-type)))
+(content-type (notmuch-show--plist-get part :content-type)))
(list content content-type)
 
 (defun notmuch-show-setup-w3m ()
@@ -620,7 +624,7 @@ will return nil if the CID is unknown or cannot be 
retrieved."
 ;; MIME part renderers
 
 (defun notmuch-show-multipart/*-to-list (part)
-  (mapcar (lambda (inner-part) (plist-get inner-part :content-type))
+  (mapcar (lambda (inner-part) (notmuch-show--plist-get inner-part 
:content-type))
  (plist-get part :content)))
 
 (defun notmuch-show-insert-part-multipart/alternative (msg part content-type 
nth depth button)
@@ -631,7 +635,7 @@ will return nil if the CID is unknown or cannot be 
retrieved."
 ;; but it's not clear that this is the wrong thing to do - which
 ;; should be chosen if there are more than one that match?
 (mapc (lambda (inner-part)
-   (let* ((inner-type (plist-get inner-part :content-type))
+   (let* ((inner-type (notmuch-show--plist-get inner-part 
:content-type))
  (hide (not (or notmuch-show-all-multipart/alternative-parts
   (string= chosen-type inner-type)
  (notmuch-show-insert-bodypart msg inner-part depth hide)))
@@ -948,7 +952,7 @@ will return nil if the CID is unknown or cannot be 
retrieved."
 
 (defun notmuch-show-mime-type (part)
   "Return the correct mime-type to use for PART."
-  (let ((content-type (downcase (plist-get part :content-type
+  (let ((content-type (downcase (notmuch-show--plist-get part :content-type
 (or (and (string= content-type "application/octet-stream")
 (notmuch-show-get-mime-type-of-application/octet-stream part))
(and (string= content-type "inline patch")
@@ -989,7 +993,7 @@ HIDE determines whether to show or hide the part and the 
button
 as follows: If HIDE is nil, show the part and the button. If HIDE
 is t, hide the part initially and show the button."
 
-  (let* ((content-type (downcase (plist-get part :content-type)))
+  (let* ((content-type (downcase (notmuch-show--plist-get part :content-type)))
 (mime-type (notmuch-show-mime-type part))
 (nth (plist-get part :id))
 (long (and (notmuch-match-content-type mime-type "text/*")
-- 
2.24.0.rc0

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: Missing in 0.29.2 notmuch-dump.c: Fix output file being closed twice

2019-10-24 Thread David Bremner
Ralph Seichter  writes:

> * David Bremner:
>
>> That push was pushed to master, but not release. I guess at the time
>> it didn't seem serious enough to warrant a point release?
>
> I did not expect a point release for that patch in particular. However,
> given that the patch fixed a SIGABRT situation, I have assumed to see it
> included in whatever release came next. Version 0.29.2 happens to be the
> first release since the bugfix was accepted three months ago, hence my
> moderate disappointment that the fix is missing.

I understand your disappointment. I fully expected to have normal
release before now, but life happens.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: Missing in 0.29.2 notmuch-dump.c: Fix output file being closed twice

2019-10-24 Thread Ralph Seichter
* David Bremner:

> That push was pushed to master, but not release. I guess at the time
> it didn't seem serious enough to warrant a point release?

I did not expect a point release for that patch in particular. However,
given that the patch fixed a SIGABRT situation, I have assumed to see it
included in whatever release came next. Version 0.29.2 happens to be the
first release since the bugfix was accepted three months ago, hence my
moderate disappointment that the fix is missing.

-Ralph
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: Missing in 0.29.2 notmuch-dump.c: Fix output file being closed twice

2019-10-24 Thread David Bremner
David Bremner  writes:

> Ralph Seichter  writes:
>
>> Folks,
>>
>> On July 23, in message <20190723203002.31110-1-ab...@monksofcool.net>,
>> I submitted a patch that appears to be missing from release 0.29.2.
>> In <87ef2frw15@tethera.net> David Bremner wrote that the fix was
>> supposed to be pushed, so I am a bit confused.
>>
>> -Ralph
>
> That push was pushed to master, but not release. I guess at the time it
> didn't seem serious enough to warrant a point release? I'd have to go
> back an re-examine the email thread to be sure.

To clarify, that fix will be in 0.30

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: Missing in 0.29.2 notmuch-dump.c: Fix output file being closed twice

2019-10-24 Thread David Bremner
Ralph Seichter  writes:

> Folks,
>
> On July 23, in message <20190723203002.31110-1-ab...@monksofcool.net>,
> I submitted a patch that appears to be missing from release 0.29.2.
> In <87ef2frw15@tethera.net> David Bremner wrote that the fix was
> supposed to be pushed, so I am a bit confused.
>
> -Ralph

That push was pushed to master, but not release. I guess at the time it
didn't seem serious enough to warrant a point release? I'd have to go
back an re-examine the email thread to be sure.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch