user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH] address: remove Address::from_name
@ 2016-06-25 21:36  7% Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2016-06-25 21:36 UTC (permalink / raw)
  To: meta

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


^ permalink raw reply	[relevance 7%]

Results 1-1 of 1 | reverse | sort options + mbox downloads above
-- links below jump to the message on this page --
2016-06-25 21:36  7% [PATCH] address: remove Address::from_name Eric Wong

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

	https://80x24.org/public-inbox.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).