]> git.cworth.org Git - notmuch/commitdiff
cli: sanitize tabs and newlines to spaces in notmuch search
authorJani Nikula <jani@nikula.org>
Mon, 3 Feb 2014 19:51:41 +0000 (21:51 +0200)
committerDavid Bremner <david@tethera.net>
Sun, 9 Mar 2014 13:12:52 +0000 (10:12 -0300)
Sanitize tabs and newlines to spaces rather than question marks in
--output=summary --format=text output.

This will also hide any difference in unfolding a header that has been
folded with a tab. Our own header parser replaces tabs with spaces,
while gmime would retain the tab.

notmuch-search.c
test/T090-search-output.sh

index 91b5d10596dc987cd8b3bafb18dadb17f57a7384..0262eb30a1f96829141b4fd6cc7b20ecf141ff2e 100644 (file)
@@ -41,7 +41,9 @@ sanitize_string (const void *ctx, const char *str)
     loop = out = talloc_strdup (ctx, str);
 
     for (; *loop; loop++) {
-       if ((unsigned char)(*loop) < 32)
+       if (*loop == '\t' || *loop == '\n')
+           *loop = ' ';
+       else if ((unsigned char)(*loop) < 32)
            *loop = '?';
     }
     return out;
index 5ccfeaf914847966b3a2b92b1627d7769a460f09..86544ac956a1dbaf0443d0bd286be0e02a496343 100755 (executable)
@@ -388,7 +388,7 @@ add_message "[subject]='two =?ISO-8859-1?Q?line=0A_subject?=
        headers'"
 notmuch search id:"$gen_msg_id" | notmuch_search_sanitize >OUTPUT
 cat <<EOF >EXPECTED
-thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; two line? subject headers (inbox unread)
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; two line  subject headers (inbox unread)
 EOF
 test_expect_equal_file OUTPUT EXPECTED