Address: renamed $domain/$domain_re (clearer)
and added a couple more tests
This commit is contained in:
parent
2aaedbb445
commit
7576e64f70
@ -195,27 +195,27 @@ sub canonify {
|
|||||||
};
|
};
|
||||||
$path = $1;
|
$path = $1;
|
||||||
|
|
||||||
my $domain = $domain_expr || "$subdomain_expr(?:\.$subdomain_expr)*";
|
my $domain_re = $domain_expr || "$subdomain_expr(?:\.$subdomain_expr)*";
|
||||||
|
|
||||||
# $address_literal_expr may be empty, if a site doesn't allow them
|
# $address_literal_expr may be empty, if a site doesn't allow them
|
||||||
if (!$domain_expr && $address_literal_expr) {
|
if (!$domain_expr && $address_literal_expr) {
|
||||||
$domain = "(?:$address_literal_expr|$domain)";
|
$domain_re = "(?:$address_literal_expr|$domain_re)";
|
||||||
};
|
};
|
||||||
|
|
||||||
# strip source route
|
# strip source route
|
||||||
$path =~ s/^\@$domain(?:,\@$domain)*://;
|
$path =~ s/^\@$domain_re(?:,\@$domain_re)*://;
|
||||||
|
|
||||||
# empty path is ok
|
# empty path is ok
|
||||||
if ($path eq '') {
|
if ($path eq '') {
|
||||||
return '', undef, 'empty path';
|
return '', undef, 'empty path';
|
||||||
};
|
};
|
||||||
|
|
||||||
# bare postmaster is permissible, perl RFC-2821 (4.5.1)
|
# bare postmaster is permissible, per RFC-2821 (4.5.1)
|
||||||
if ( $path =~ m/^postmaster$/i ) {
|
if ( $path =~ m/^postmaster$/i ) {
|
||||||
return 'postmaster', undef, 'bare postmaster';
|
return 'postmaster', undef, 'bare postmaster';
|
||||||
}
|
}
|
||||||
|
|
||||||
my ($localpart, $domainpart) = ($path =~ /^(.*)\@($domain)$/);
|
my ($localpart, $domainpart) = $path =~ /^(.*)\@($domain_re)$/;
|
||||||
if (!defined $localpart) {
|
if (!defined $localpart) {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -207,6 +207,13 @@ sub __canonify {
|
|||||||
@r = Qpsmtpd::Address->canonify('<postmaster@test>');
|
@r = Qpsmtpd::Address->canonify('<postmaster@test>');
|
||||||
is_deeply(\@r, [ 'postmaster', 'test', 'local matches atom' ], 'canonify, postmaster@test');
|
is_deeply(\@r, [ 'postmaster', 'test', 'local matches atom' ], 'canonify, postmaster@test');
|
||||||
|
|
||||||
|
@r = Qpsmtpd::Address->canonify('<@a:postmaster@test>');
|
||||||
|
is_deeply(\@r, [ 'postmaster', 'test', 'local matches atom' ], 'canonify, @a:postmaster@test (source route)');
|
||||||
|
|
||||||
@r = Qpsmtpd::Address->canonify('<postmáster@test>');
|
@r = Qpsmtpd::Address->canonify('<postmáster@test>');
|
||||||
is_deeply(\@r, [ 'postmáster', 'test', 'local matches atom' ], 'canonify, postmáster@test, local matches atom');
|
is_deeply(\@r, [ 'postmáster', 'test', 'local matches atom' ], 'canonify, postmáster@test, local matches atom');
|
||||||
|
|
||||||
|
@r = Qpsmtpd::Address->canonify('<@192.168.1.1>');
|
||||||
|
is_deeply(\@r, [ undef, undef, 'fall through' ], 'canonify, fall through, @192.168.1.1')
|
||||||
|
or diag Data::Dumper::Dumper(@r);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user