From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH ssoma] remove Email::Address dependency
Date: Wed, 25 May 2016 02:28:59 +0000 [thread overview]
Message-ID: <20160525022859.GA7059@dcvr.yhbt.net> (raw)
git has stricter requirements for ident names (no '<>')
which Email::Address allows.
Even in 1.908, Email::Address also has an incomplete fix for
CVE-2015-7686 with a DoS-able regexp for comments. Since we
don't care for or need all the RFC compliance of Email::Address,
avoiding it entirely may be preferable.
Email::Address will still be installed as a requirement for
Email::MIME, but it is only used by the
Email::MIME::header_str_set which we do not use (not even in
public-inbox).
---
INSTALL | 1 -
Makefile.PL | 1 -
lib/Ssoma/MDA.pm | 17 +++++++++++------
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/INSTALL b/INSTALL
index 72affff..6a03f37 100644
--- a/INSTALL
+++ b/INSTALL
@@ -36,7 +36,6 @@ convenience.
* any MUA capable of reading/importing IMAP, mbox(5) or Maildir
* Perl and several modules: (Debian package name (7.0))
- Digest::SHA perl
- - Email::Address libemail-address-perl
- Email::LocalDelivery libemail-localdelivery-perl
- Email::MIME libemail-mime-perl
- File::Path::Expand libfile-path-expand-perl
diff --git a/Makefile.PL b/Makefile.PL
index bbf784d..b16c17c 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -19,7 +19,6 @@ WriteMakefile(
PREREQ_PM => {
# Keep this sorted and synced to the INSTALL document
'Digest::SHA' => 0,
- 'Email::Address' => 0,
'Email::LocalDelivery' => 0,
'Email::MIME' => 0,
'IPC::Run' => 0,
diff --git a/lib/Ssoma/MDA.pm b/lib/Ssoma/MDA.pm
index 0a6d27d..8397a2b 100644
--- a/lib/Ssoma/MDA.pm
+++ b/lib/Ssoma/MDA.pm
@@ -6,7 +6,6 @@ package Ssoma::MDA;
use strict;
use warnings;
use Ssoma::GitIndexInfo;
-use Email::Address;
sub new {
my ($class, $git) = @_;
@@ -106,14 +105,20 @@ sub append {
{
my $from = $mime->header('From');
- my @from = Email::Address->parse($from);
- my $name = $from[0]->name;
- my $email = $from[0]->address;
+ my (@email) = ($from =~ /([^<\s]+\@[^>\s]+)/g);
+ my $name = $from;
+ $name =~ s/\s*\S+\@.*\S+\s*//;
+ my $email = $email[0] || 'invalid@example';
+ if ($name !~ /\S/ || $name =~ /[<>]/) {
+ $name = $email[0];
+ $name =~ s/\@.*//;
+ }
+ $name =~ s/\A\s*//;
my $date = $mime->header('Date');
my $subject = $mime->header("Subject");
$subject = '(no subject)' unless defined $subject;
- local $ENV{GIT_AUTHOR_NAME} ||= $name if defined $name;
- local $ENV{GIT_AUTHOR_EMAIL} ||= $email if defined $email;
+ local $ENV{GIT_AUTHOR_NAME} ||= $name;
+ local $ENV{GIT_AUTHOR_EMAIL} ||= $email[0];
local $ENV{GIT_AUTHOR_DATE} ||= $date if defined $date;
$git->commit_index($gii, 0, $ref, $subject);
}
--
EW
next reply other threads:[~2016-05-25 2:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-25 2:28 Eric Wong [this message]
2016-05-25 2:29 ` [PATCH inbox] remove Email::Address dependency Eric Wong
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=20160525022859.GA7059@dcvr.yhbt.net \
--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).