From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] address: remove Address::from_name
Date: Sat, 25 Jun 2016 21:36:48 +0000 [thread overview]
Message-ID: <20160625213648.6571-1-e@80x24.org> (raw)
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
reply other threads:[~2016-06-25 21:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160625213648.6571-1-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public 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).