user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH ssoma] remove Email::Address dependency
@ 2016-05-25  2:28 Eric Wong
  2016-05-25  2:29 ` [PATCH inbox] " Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2016-05-25  2:28 UTC (permalink / raw)
  To: meta

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-25  2:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-25  2:28 [PATCH ssoma] remove Email::Address dependency Eric Wong
2016-05-25  2:29 ` [PATCH inbox] " Eric Wong

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).