From 23a4e44bedabe5b8b651346cabc2a870c5377a30 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 25 May 2016 01:44:46 +0000 Subject: remove Email::Address dependency 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 --- lib/PublicInbox/Address.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/PublicInbox/Address.pm (limited to 'lib/PublicInbox/Address.pm') diff --git a/lib/PublicInbox/Address.pm b/lib/PublicInbox/Address.pm new file mode 100644 index 00000000..ef4cbdc6 --- /dev/null +++ b/lib/PublicInbox/Address.pm @@ -0,0 +1,25 @@ +# Copyright (C) 2016 all contributors +# License: AGPL-3.0+ +package PublicInbox::Address; +use strict; +use warnings; + +# very loose regexes, here. We don't need RFC-compliance, +# just enough to make thing sanely displayable and pass to git + +sub emails { ($_[0] =~ /([^<\s]+\@[^>\s]+)/g) } + +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; +} + +1; -- cgit v1.2.3-24-ge0c7