aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-show.c
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2010-06-05 08:40:26 -0700
committerGravatar Carl Worth <cworth@cworth.org>2010-06-05 08:40:26 -0700
commit9c7668bdb51e4739eecda83b6452ef668ed0efa3 (patch)
tree4a8139cf7179186245a732f0df9b2ba1fc753a5a /notmuch-show.c
parent42e146a3a20c1ca2e1a9d6fd2d5e5e9d03a06641 (diff)
Avoid giving GMime a NULL MIME-stream filter.
Micah Anderson reported an issue where a message failed to display in the emacs interface, (it instead gave an error, "json-read-string: Bad string format"). Micah tracked this down to the json output from "notmuch show" being interrupted by a GMime error message: gmime-CRITICAL **: g_mime_stream_filter_add: assertion `GMIME_IS_FILTER (filter) I tracked this down further to notmuch passing a NULL value to g_mime_stream_filter_add. And this was due to calling g_mime_filter_charset_new with a value of "unknown-8bit". So we add a test message withe a Conten-Type of "text/plain; charset=unknown-8bit" from Micah's message. Then we fix "notmuch show" to test for NULL before calling g_mime_stream_filter_add. Bug fixed.
Diffstat (limited to 'notmuch-show.c')
-rw-r--r--notmuch-show.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/notmuch-show.c b/notmuch-show.c
index 26449fa5..4ed5fc74 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -225,9 +225,15 @@ show_part_content (GMimeObject *part, GMimeStream *stream_out)
g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),
g_mime_filter_crlf_new(FALSE, FALSE));
if (charset) {
- g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),
- g_mime_filter_charset_new(charset, "UTF-8"));
- }
+ GMimeFilter *charset_filter;
+ charset_filter = g_mime_filter_charset_new(charset, "UTF-8");
+ /* This result can be NULL for things like "unknown-8bit".
+ * Don't set a NULL filter as that makes GMime print
+ * annoying assertion-failure messages on stderr. */
+ if (charset_filter)
+ g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),
+ charset_filter);
+ }
}
wrapper = g_mime_part_get_content_object (GMIME_PART (part));