Hi

I attach a patch which does the quoting for real names but I don't know
if we want it: it changes (example taken from the test suite)

François Boulogne to

=?iso-8859-1?q?Fran=E7ois?= Boulogne

(which is what was in the original email)

Plausibly the best thing is just to leave the series as is, so the
text output is readable and parseable in the common cases.

Anyway the patch is attached if anyone wants to experiment.

Best wishes

Mark

>From 53b1ced2d6a9fbbba93448325f795e6b99faa240 Mon Sep 17 00:00:00 2001
From: Mark Walters <[email protected]>
Date: Fri, 31 Oct 2014 10:11:40 +0000
Subject: [PATCH] search: quote real names for output=sender/recipient in text
 format

This quotes the real name (when gmime thinks appropriate) for the text
output. For the other outputs the real name is separate from the
address so the consumer can do any quoting necessary.
---
 notmuch-search.c           |    8 ++++----
 test/T090-search-output.sh |    8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index eae749a..8eac161 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -47,6 +47,7 @@ typedef struct {
 typedef struct {
     const char *name;
     const char *addr;
+    const char *string;
 } mailbox_t;
 
 /* Return two stable query strings that identify exactly the matched
@@ -255,15 +256,13 @@ print_mailbox (const search_options_t *opt, const mailbox_t *mailbox)
 {
     const char *name = mailbox->name;
     const char *addr = mailbox->addr;
+    const char *string = mailbox->string;
     sprinter_t *format = opt->format;
 
     if (format->is_text_printer) {
 	char *mailbox_str;
 
-	if (name && *name)
-	    mailbox_str = talloc_asprintf (format, "%s <%s>", name, addr);
-	else
-	    mailbox_str = talloc_strdup (format, addr);
+	mailbox_str = talloc_strdup (format, string);
 
 	if (! mailbox_str) {
 	    fprintf (stderr, "Error: out of memory\n");
@@ -309,6 +308,7 @@ process_address_list (const search_options_t *opt, GHashTable *addrs,
 	    mailbox_t mbx = {
 		.name = internet_address_get_name (address),
 		.addr = internet_address_mailbox_get_addr (mailbox),
+		.string = internet_address_to_string (address, TRUE),
 	    };
 
 	    if (is_duplicate (opt, addrs, mbx.name, mbx.addr))
diff --git a/test/T090-search-output.sh b/test/T090-search-output.sh
index 841a721..776e3f4 100755
--- a/test/T090-search-output.sh
+++ b/test/T090-search-output.sh
@@ -390,7 +390,7 @@ test_expect_equal_file OUTPUT EXPECTED
 test_begin_subtest "--output=sender"
 notmuch search --output=sender '*' >OUTPUT
 cat <<EOF >EXPECTED
-François Boulogne <[email protected]>
+=?iso-8859-1?q?Fran=E7ois?= Boulogne <[email protected]>
 Olivier Berger <[email protected]>
 Chris Wilson <[email protected]>
 Carl Worth <[email protected]>
@@ -437,7 +437,7 @@ test_begin_subtest "--output=recipients"
 notmuch search --output=recipients '*' >OUTPUT
 cat <<EOF >EXPECTED
 Allan McRae <[email protected]>
-Discussion about the Arch User Repository (AUR) <[email protected]>
+"Discussion about the Arch User Repository (AUR)" <[email protected]>
 [email protected]
 [email protected]
 notmuch <[email protected]>
@@ -449,9 +449,9 @@ test_expect_equal_file OUTPUT EXPECTED
 test_begin_subtest "--output=sender --output=recipients"
 notmuch search --output=sender --output=recipients '*' >OUTPUT
 cat <<EOF >EXPECTED
-François Boulogne <[email protected]>
+=?iso-8859-1?q?Fran=E7ois?= Boulogne <[email protected]>
 Allan McRae <[email protected]>
-Discussion about the Arch User Repository (AUR) <[email protected]>
+"Discussion about the Arch User Repository (AUR)" <[email protected]>
 Olivier Berger <[email protected]>
 [email protected]
 Chris Wilson <[email protected]>
-- 
1.7.10.4

_______________________________________________
notmuch mailing list
[email protected]
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to