smtp: Support the SMTPUTF8 extension in the VRFY command

This commit is contained in:
Steve Holme 2020-02-13 22:56:51 +00:00
parent 483edeb8dd
commit efce3ea5a8
No known key found for this signature in database
GPG key ID: 4059CB85CA7E8F19
5 changed files with 131 additions and 8 deletions

View file

@ -1037,13 +1037,15 @@ sub VRFY_smtp {
sendcontrol "501 Unrecognized parameter\r\n";
}
else {
my $smtputf8 = grep /^SMTPUTF8$/, @capabilities;
# Validate the username (only a valid local or external username is
# allowed, such as user or user@example.com)
if ($username !~
/^([a-zA-Z0-9._%+-]+)(\@(([a-zA-Z0-9-]+)\.)+([a-zA-Z]{2,4}))?$/) {
sendcontrol "501 Invalid address\r\n";
}
else {
if ((!$smtputf8 && $username =~
/^([a-zA-Z0-9._%+-]+)(\@(([a-zA-Z0-9-]+)\.)+([a-zA-Z]{2,4}))?$/) ||
($smtputf8 && $username =~
/^([a-zA-Z0-9\x{80}-\x{ff}._%+-]+)(\@(([a-zA-Z0-9\x{80}-\x{ff}-]+)\.)+([a-zA-Z]{2,4}))?$/)) {
my @data = getreplydata($smtp_client);
if(!@data) {
@ -1060,6 +1062,9 @@ sub VRFY_smtp {
sendcontrol $d;
}
}
else {
sendcontrol "501 Invalid address\r\n";
}
}
return 0;