From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] cleanup Email::Address usage
Date: Sun, 23 Aug 2015 19:05:18 +0000 [thread overview]
Message-ID: <1440356718-8302-1-git-send-email-e@80x24.org> (raw)
Email::Address::name never fails assuming it was able to parse
anything.
---
lib/PublicInbox/Feed.pm | 2 +-
lib/PublicInbox/MDA.pm | 2 --
lib/PublicInbox/View.pm | 1 -
3 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 51216aa..f4d19e0 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -279,7 +279,7 @@ sub add_to_feed {
my $type = index($title, '&') >= 0 ? "\ntype=\"html\"" : '';
my $from = mime_header($header_obj, 'From') or return 0;
- my @from = Email::Address->parse($from);
+ my @from = Email::Address->parse($from) or return 0;
my $name = PublicInbox::Hval->new_oneline($from[0]->name)->as_html;
my $email = $from[0]->address;
$email = PublicInbox::Hval->new_oneline($email)->as_html;
diff --git a/lib/PublicInbox/MDA.pm b/lib/PublicInbox/MDA.pm
index fe04ded..16da7af 100644
--- a/lib/PublicInbox/MDA.pm
+++ b/lib/PublicInbox/MDA.pm
@@ -88,9 +88,7 @@ sub author_info {
my $from = $mime->header('From');
my @from = Email::Address->parse($from);
my $name = $from[0]->name;
- defined $name or $name = '';
my $email = $from[0]->address;
- defined $email or $email = '';
($name, $email, $mime->header('Date'));
}
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index fe37a9f..f4e7282 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -65,7 +65,6 @@ sub index_entry {
my $from = PublicInbox::Hval->new_oneline($mime->header('From'))->raw;
my @from = Email::Address->parse($from);
$from = $from[0]->name;
- (defined($from) && length($from)) or $from = $from[0]->address;
$from = PublicInbox::Hval->new_oneline($from)->as_html;
$subj = PublicInbox::Hval->new_oneline($subj)->as_html;
--
EW
reply other threads:[~2015-08-23 19:05 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1440356718-8302-1-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.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.
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).