From acac0cfb3afa26fd6556aa9f835869febcda97d8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 6 Jul 2016 00:36:59 +0000 Subject: address: attempt to handle comments somewhat They're uncommon, fortunately, but we make no attempt to handle nested comments (which would open us up to things like CVE-2015-7686) or use the comment in place of a missing name. --- t/address.t | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 't') diff --git a/t/address.t b/t/address.t index 3191fed0..287fcfa0 100644 --- a/t/address.t +++ b/t/address.t @@ -20,4 +20,13 @@ is_deeply(['User', 'e', 'John A. Doe', 'x'], \@names, @names = PublicInbox::Address::names('"user@example.com" '); is_deeply(['user'], \@names, 'address-as-name extraction works as expected'); + +{ + my $backwards = 'u@example.com (John Q. Public)'; + @names = PublicInbox::Address::names($backwards); + is_deeply(\@names, ['u'], 'backwards name OK'); + my @emails = PublicInbox::Address::emails($backwards); + is_deeply(\@emails, ['u@example.com'], 'backwards emails OK'); +} + done_testing; -- cgit v1.2.3-24-ge0c7