diff --git a/lib/Qpsmtpd/Address.pm b/lib/Qpsmtpd/Address.pm index ad5159e..939a253 100644 --- a/lib/Qpsmtpd/Address.pm +++ b/lib/Qpsmtpd/Address.pm @@ -195,27 +195,27 @@ sub canonify { }; $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 if (!$domain_expr && $address_literal_expr) { - $domain = "(?:$address_literal_expr|$domain)"; + $domain_re = "(?:$address_literal_expr|$domain_re)"; }; # strip source route - $path =~ s/^\@$domain(?:,\@$domain)*://; + $path =~ s/^\@$domain_re(?:,\@$domain_re)*://; # empty path is ok if ($path eq '') { 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 ) { return 'postmaster', undef, 'bare postmaster'; } - my ($localpart, $domainpart) = ($path =~ /^(.*)\@($domain)$/); + my ($localpart, $domainpart) = $path =~ /^(.*)\@($domain_re)$/; if (!defined $localpart) { return; }; diff --git a/t/qpsmtpd-address.t b/t/qpsmtpd-address.t index 2fc7dec..94fa11c 100644 --- a/t/qpsmtpd-address.t +++ b/t/qpsmtpd-address.t @@ -207,6 +207,13 @@ sub __canonify { @r = Qpsmtpd::Address->canonify(''); 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(''); 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); }