[PATCH 1/2] lib: Use email address instead of empty real name.

Jesse Rosenthal jrosenthal at jhu.edu
Fri Nov 21 07:46:43 PST 2014


Currently, if a From-header is of the form:

    "" <address at example.com>

the empty string will be treated as a valid real-name, and the entry
in the search results will be empty.

The new behavior here is that we treat an empty real-name field as if
it were null, so that the email address will be used in the search
results instead.

Signed-off-by: Jesse Rosenthal <jrosenthal at jhu.edu>
---
 lib/thread.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/thread.cc b/lib/thread.cc
index 8922403..68b2b94 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -277,7 +277,8 @@ _thread_add_message (notmuch_thread_t *thread,
 	address = internet_address_list_get_address (list, 0);
 	if (address) {
 	    author = internet_address_get_name (address);
-	    if (author == NULL) {
+	    // We treat quoted empty names as if they were empty.
+	    if (author == NULL || author[0]=='\0' ) {
 		InternetAddressMailbox *mailbox;
 		mailbox = INTERNET_ADDRESS_MAILBOX (address);
 		author = internet_address_mailbox_get_addr (mailbox);
-- 
2.1.3


>From 90fd4673e08fccef95dcc0050bdcac3773d336a9 Mon Sep 17 00:00:00 2001
From: Jesse Rosenthal <jrosenthal at jhu.edu>
Date: Fri, 21 Nov 2014 10:24:16 -0500
Subject: [PATCH 2/2] test: Add test for correct naming of author.

This is a new test file, since handling of unusual email addresses
doesn't seem to fit well in any of our existing tests.

Signed-off-by: Jesse Rosenthal <jrosenthal at jhu.edu>
---
 test/T205-author-naming.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100755 test/T205-author-naming.sh

diff --git a/test/T205-author-naming.sh b/test/T205-author-naming.sh
new file mode 100755
index 0000000..cb678ae
--- /dev/null
+++ b/test/T205-author-naming.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+test_description="naming of authors with unusual addresses"
+. ./test-lib.sh
+
+test_begin_subtest "Add author with empty quoted real name"
+add_message '[subject]="author-naming: Initial thread subject"' \
+	    '[date]="Fri, 05 Jan 2001 15:43:56 -0000"' \
+	    '[from]="\"\" <address at example.com>"'
+output=$(notmuch search --sort=oldest-first author-naming and tag:inbox | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] address at example.com; author-naming: Initial thread subject (inbox unread)"
+
+test_done
-- 
2.1.3



More information about the notmuch mailing list