From 53b1ced2d6a9fbbba93448325f795e6b99faa240 Mon Sep 17 00:00:00 2001 From: Mark Walters 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 <EXPECTED -François Boulogne +=?iso-8859-1?q?Fran=E7ois?= Boulogne Olivier Berger Chris Wilson Carl Worth @@ -437,7 +437,7 @@ test_begin_subtest "--output=recipients" notmuch search --output=recipients '*' >OUTPUT cat <EXPECTED Allan McRae -Discussion about the Arch User Repository (AUR) +"Discussion about the Arch User Repository (AUR)" olivier.berger@it-sudparis.eu notmuch@notmuchmail.org notmuch @@ -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 <EXPECTED -François Boulogne +=?iso-8859-1?q?Fran=E7ois?= Boulogne Allan McRae -Discussion about the Arch User Repository (AUR) +"Discussion about the Arch User Repository (AUR)" Olivier Berger olivier.berger@it-sudparis.eu Chris Wilson -- 1.7.10.4