From 01d25810ec9baf643e2a278a0fefdf857bfd3883 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 14 Dec 2019 01:02:55 +0000 Subject: address: use comment as name if no phrase available Some users will set their From: headers in the form of: " (A U Thor)", where their name is in the parenthesized comment. Use that instead of the email address, if available. --- t/address.t | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 't') diff --git a/t/address.t b/t/address.t index bea45daa..2a287102 100644 --- a/t/address.t +++ b/t/address.t @@ -14,8 +14,9 @@ is_deeply(['user@example.com'], 'comment after domain accepted before >'); my @names = PublicInbox::Address::names( - 'User , e@e, "John A. Doe" , '); -is_deeply(['User', 'e', 'John A. Doe', 'x'], \@names, + 'User , e@e, "John A. Doe" , , (xyz), '. + 'U Ser (do not use)'); +is_deeply(\@names, ['User', 'e', 'John A. Doe', 'x', 'xyz', 'U Ser'], 'name extraction works as expected'); @names = PublicInbox::Address::names('"user@example.com" '); @@ -25,7 +26,7 @@ is_deeply(['user'], \@names, 'address-as-name extraction works as expected'); { my $backwards = 'u@example.com (John Q. Public)'; @names = PublicInbox::Address::names($backwards); - is_deeply(\@names, ['u'], 'backwards name OK'); + is_deeply(\@names, ['John Q. Public'], 'backwards name OK'); my @emails = PublicInbox::Address::emails($backwards); is_deeply(\@emails, ['u@example.com'], 'backwards emails OK'); } -- cgit v1.2.3-24-ge0c7