File: email_addr_regex.t

package info (click to toggle)
libmail-deliverystatus-bounceparser-perl 1.542%2Brepacked-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,044 kB
  • sloc: perl: 1,684; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,323 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!perl -wT
use strict;

use Test::More tests => 16;
use Mail::DeliveryStatus::BounceParser;

my $regex = $Mail::DeliveryStatus::BounceParser::EMAIL_ADDR_REGEX;

my @ok_addrs = ('TEST-ING@example.com',
                'my_email_address@example.net',
                'fakeaddress.123@us.example.com',
                'bogus@example.co.uk',
                'not-arealaddress@emh15.invalid.army.mil',
                '"recipient:lycos.com"@mail.lycos.com-us4cluster7.as.int',
                '&-@no.spam.example.com'
                );

my @bad_addrs = ('enI@rgement',          # yay spammers
                 'ide@$',
                 'embarr@$sment',
                 'href="http://mukrasa.info/del.php?mail=address@example.com',  # We don't want the whole thing
                 'MYADDRESS@YAHOO',      # Invalid domain name 
                 'Person@!yahoo.com',    # invalid char in hostname
                 'face="@r1aI"',         # more HTML garbage
                 'Amig@:/FONT></P',      # yet more
                );

like($_, $regex , "\"$_\" is Ok") for @ok_addrs;
unlike($_, $regex , "\"$_\" is Ok") for @bad_addrs;

# This caused some problems, initially
my $addr;
my $string = 'RCPT TO:<luser@example.com>:';
if ($string =~ $regex) {
  $addr = $1;
}
is($addr, 'luser@example.com', "We got the right address");