Address::names is sufficient to handle what from_name did.
---
 lib/PublicInbox/Address.pm   | 14 --------------
 lib/PublicInbox/Feed.pm      |  2 +-
 lib/PublicInbox/SearchMsg.pm |  3 ++-
 lib/PublicInbox/View.pm      |  4 ++--
 t/mda.t                      |  2 +-
 5 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/lib/PublicInbox/Address.pm b/lib/PublicInbox/Address.pm
index abba43d..cd5fbfb 100644
--- a/lib/PublicInbox/Address.pm
+++ b/lib/PublicInbox/Address.pm
@@ -20,18 +20,4 @@ sub names {
        } split(/\@+[\w\.\-]+>?\s*(?:,\s*|\z)/, $_[0]);
 }
 
-sub from_name {
-       my ($val) = @_;
-       my $name = $val;
-       $name =~ s/\s*\S+\@\S+\s*\z//;
-       if ($name !~ /\S/ || $name =~ /[<>]/) { # git does not like [<>]
-               ($name) = emails($val);
-               $name =~ s/\@.*//;
-       }
-       $name =~ tr/\r\n\t/ /;
-       $name =~ s/\A['"\s]*//;
-       $name =~ s/['"\s]*\z//;
-       $name;
-}
-
 1;
diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 455b8e2..8e23306 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -317,7 +317,7 @@ sub feed_entry {
 
        my $from = $header_obj->header('From') or return;
        my ($email) = PublicInbox::Address::emails($from);
-       my $name = PublicInbox::Address::from_name($from);
+       my $name = join(', ',PublicInbox::Address::names($from));
        $name = ascii_html($name);
        $email = ascii_html($email);
 
diff --git a/lib/PublicInbox/SearchMsg.pm b/lib/PublicInbox/SearchMsg.pm
index d41d243..4b0b645 100644
--- a/lib/PublicInbox/SearchMsg.pm
+++ b/lib/PublicInbox/SearchMsg.pm
@@ -85,7 +85,8 @@ sub from ($) {
        my ($self) = @_;
        my $from = __hdr($self, 'from');
        if (defined $from && !defined $self->{from_name}) {
-               $self->{from_name} = PublicInbox::Address::from_name($from);
+               my @n = PublicInbox::Address::names($from);
+               $self->{from_name} = join(', ', @n);
        }
        $from;
 }
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index d906276..30d8e3e 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -354,8 +354,8 @@ sub _msg_html_prepare {
                $v = PublicInbox::Hval->new($v);
 
                if ($h eq 'From') {
-                       my $n = PublicInbox::Address::from_name($v->raw);
-                       $title[1] = ascii_html($n);
+                       my @n = PublicInbox::Address::names($v->raw);
+                       $title[1] = ascii_html(join(', ', @n));
                } elsif ($h eq 'Subject') {
                        $title[0] = $v->as_html;
                        if ($srch) {
diff --git a/t/mda.t b/t/mda.t
index f3c5164..32154bd 100644
--- a/t/mda.t
+++ b/t/mda.t
@@ -57,7 +57,7 @@ local $ENV{GIT_COMMITTER_NAME} = eval {
        my $msg = Email::MIME->new($str);
 
        my $from = $msg->header('From');
-       my $author = PublicInbox::Address::from_name($from);
+       my ($author) = PublicInbox::Address::names($from);
        my ($email) = PublicInbox::Address::emails($from);
        my $date = $msg->header('Date');
 
-- 
EW

--
unsubscribe: meta+unsubscr...@public-inbox.org
archive: https://public-inbox.org/meta/

Reply via email to