unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v2 0/2] Use email address instead of empty real name.
@ 2014-11-21 15:57 Jesse Rosenthal
  2014-11-21 15:57 ` [PATCH v2 1/2] lib: " Jesse Rosenthal
  2014-11-21 15:57 ` [PATCH v2 2/2] test: Add test for correct naming of author Jesse Rosenthal
  0 siblings, 2 replies; 5+ messages in thread
From: Jesse Rosenthal @ 2014-11-21 15:57 UTC (permalink / raw)
  To: notmuch

Apologies. A git (-user) malfunction in v1 accidentally sent the whole
mbox as one patch. These are the correct patches.

Jesse Rosenthal (2):
  lib: Use email address instead of empty real name.
  test: Add test for correct naming of author.

 lib/thread.cc              |  3 ++-
 test/T205-author-naming.sh | 12 ++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100755 test/T205-author-naming.sh

-- 
2.1.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] lib: Use email address instead of empty real name.
  2014-11-21 15:57 [PATCH v2 0/2] Use email address instead of empty real name Jesse Rosenthal
@ 2014-11-21 15:57 ` Jesse Rosenthal
  2014-11-22 11:29   ` Jani Nikula
  2014-11-21 15:57 ` [PATCH v2 2/2] test: Add test for correct naming of author Jesse Rosenthal
  1 sibling, 1 reply; 5+ messages in thread
From: Jesse Rosenthal @ 2014-11-21 15:57 UTC (permalink / raw)
  To: notmuch

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

    "" <address@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@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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] test: Add test for correct naming of author.
  2014-11-21 15:57 [PATCH v2 0/2] Use email address instead of empty real name Jesse Rosenthal
  2014-11-21 15:57 ` [PATCH v2 1/2] lib: " Jesse Rosenthal
@ 2014-11-21 15:57 ` Jesse Rosenthal
  2014-11-22 11:31   ` Jani Nikula
  1 sibling, 1 reply; 5+ messages in thread
From: Jesse Rosenthal @ 2014-11-21 15:57 UTC (permalink / raw)
  To: notmuch

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@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@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@example.com; author-naming: Initial thread subject (inbox unread)"
+
+test_done
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] lib: Use email address instead of empty real name.
  2014-11-21 15:57 ` [PATCH v2 1/2] lib: " Jesse Rosenthal
@ 2014-11-22 11:29   ` Jani Nikula
  0 siblings, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2014-11-22 11:29 UTC (permalink / raw)
  To: Jesse Rosenthal, notmuch

On Fri, 21 Nov 2014, Jesse Rosenthal <jrosenthal@jhu.edu> wrote:
> Currently, if a From-header is of the form:
>
>     "" <address@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.

Makes sense.

> Signed-off-by: Jesse Rosenthal <jrosenthal@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.

Nitpick, we don't use // style comments.

> +	    if (author == NULL || author[0]=='\0' ) {

Nitpick, please add spaces around "==" but no space before closing ")".


BR,
Jani.

>  		InternetAddressMailbox *mailbox;
>  		mailbox = INTERNET_ADDRESS_MAILBOX (address);
>  		author = internet_address_mailbox_get_addr (mailbox);
> -- 
> 2.1.3
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] test: Add test for correct naming of author.
  2014-11-21 15:57 ` [PATCH v2 2/2] test: Add test for correct naming of author Jesse Rosenthal
@ 2014-11-22 11:31   ` Jani Nikula
  0 siblings, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2014-11-22 11:31 UTC (permalink / raw)
  To: Jesse Rosenthal, notmuch

On Fri, 21 Nov 2014, Jesse Rosenthal <jrosenthal@jhu.edu> wrote:
> This is a new test file, since handling of unusual email addresses
> doesn't seem to fit well in any of our existing tests.

It would be nice to have this as patch 1/2 annotated with "known broken"
and have the implementation patch fix it. It's nice to see that the
patch actually changes things! ;)

BR,
Jani.

>
> Signed-off-by: Jesse Rosenthal <jrosenthal@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@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@example.com; author-naming: Initial thread subject (inbox unread)"
> +
> +test_done
> -- 
> 2.1.3
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-22 11:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-21 15:57 [PATCH v2 0/2] Use email address instead of empty real name Jesse Rosenthal
2014-11-21 15:57 ` [PATCH v2 1/2] lib: " Jesse Rosenthal
2014-11-22 11:29   ` Jani Nikula
2014-11-21 15:57 ` [PATCH v2 2/2] test: Add test for correct naming of author Jesse Rosenthal
2014-11-22 11:31   ` Jani Nikula

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).