]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/Address.pm
2c0bb040e785ddaa0cb2e9ad01394b06f11dc005
[public-inbox.git] / lib / PublicInbox / Address.pm
1 # Copyright (C) 2016 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 package PublicInbox::Address;
4 use strict;
5 use warnings;
6
7 # very loose regexes, here.  We don't need RFC-compliance,
8 # just enough to make thing sanely displayable and pass to git
9
10 sub emails {
11         ($_[0] =~ /([\w\.\+=\-]+\@[\w\.\-]+)>?\s*(?:\(.*?\))?(?:,\s*|\z)/g)
12 }
13
14 sub names {
15         map {
16                 tr/\r\n\t/ /;
17                 s/\s*<([^<]+)\z//;
18                 my $e = $1;
19                 s/\A['"\s]*//;
20                 s/['"\s]*\z//;
21                 $e = $_ =~ /\S/ ? $_ : $e;
22                 $e =~ s/\@\S+\z//;
23                 $e;
24         } split(/\@+[\w\.\-]+>?\s*(?:\(.*?\))?(?:,\s*|\z)/, $_[0]);
25 }
26
27 1;