From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED shortcircuit=no autolearn=unavailable autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5C4791FCC4; Wed, 25 May 2016 02:28:36 +0000 (UTC) Date: Wed, 25 May 2016 02:28:59 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [PATCH ssoma] remove Email::Address dependency Message-ID: <20160525022859.GA7059@dcvr.yhbt.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline List-Id: 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