about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-06-25 07:19:10 +0000
committerEric Wong <e@80x24.org>2016-06-25 09:38:31 +0000
commit18011be3dbfecb3abe4bea8cdf7f0ee7dfa2f8be (patch)
tree40738a8ad7af8423c06546c1cd78afe696d21396 /lib
parent8f5c76542fe6e0b78095c3a748fd10dd01a714ef (diff)
downloadpublic-inbox-18011be3dbfecb3abe4bea8cdf7f0ee7dfa2f8be.tar.gz
We may remove from_name in the future.

...And disallow quotes in email addresses.
Technically I believe they're allowed, but they're definitely
uncommon and unlikely to show up in legitimate mail.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Address.pm13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/PublicInbox/Address.pm b/lib/PublicInbox/Address.pm
index 772adedb..abba43d1 100644
--- a/lib/PublicInbox/Address.pm
+++ b/lib/PublicInbox/Address.pm
@@ -7,7 +7,18 @@ 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 emails { ($_[0] =~ /([\w\.\+=\-]+\@[\w\.\-]+)>?\s*(?:,\s*|\z)/g) }
+
+sub names {
+        map {
+                tr/\r\n\t/ /;
+                s/\s*<([^<]+)\z//;
+                my $e = $1;
+                s/\A['"\s]*//;
+                s/['"\s]*\z//;
+                $_ =~ /\S/ ? $_ : $e;
+        } split(/\@+[\w\.\-]+>?\s*(?:,\s*|\z)/, $_[0]);
+}
 
 sub from_name {
         my ($val) = @_;