1 # Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 package PublicInbox::AddressPP;
6 # very loose regexes, here. We don't need RFC-compliance,
7 # just enough to make thing sanely displayable and pass to git
8 # We favor Email::Address::XS for conformance if available
11 ($_[0] =~ /([\w\.\+=\?"\(\)\-!#\$%&'\*\/\^\`\|\{\}~]+\@[\w\.\-\(\)]+)
12 (?:\s[^>]*)?>?\s*(?:\(.*?\))?(?:,\s*|\z)/gx)
16 my @p = split(/<?([^@<>]+)\@[\w\.\-]+>?\s*(\(.*?\))?(?:,\s*|\z)/,
19 for (my $i = 0; $i <= $#p;) {
20 my $phrase = $p[$i++];
21 $phrase =~ tr/\r\n\t / /s;
22 $phrase =~ s/\A['"\s]*//;
23 $phrase =~ s/['"\s]*\z//;
24 my $user = $p[$i++] // '';
25 my $comment = $p[$i++] // '';
26 if ($phrase =~ /\S/) {
27 $phrase =~ s/\@\S+\z//;
29 } elsif ($comment =~ /\A\((.*?)\)\z/) {