From aba1bf630f13a77b1a92484feb365a29bb1a25da Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Thu, 13 Feb 2020 20:59:36 +0000 Subject: smtp: Support the SMTPUTF8 extension in the MAIL command Support the SMTPUTF8 extension when sending mailbox information in the MAIL command (FROM and AUTH parameters). Non-ASCII domain names will be ACE encoded, if IDN is supported, whilst non-ASCII characters in the local address part are passed to the server. Reported-by: ygthien on github Fixes #4828 --- tests/ftpserver.pl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'tests/ftpserver.pl') diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index 59a1665bd..fe74f8b07 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -813,6 +813,7 @@ sub MAIL_smtp { else { my $from; my $size; + my $smtputf8 = grep /^SMTPUTF8$/, @capabilities; my @elements = split(/ /, $args); # Get the FROM and SIZE parameters @@ -827,11 +828,11 @@ sub MAIL_smtp { # Validate the from address (only <> and a valid email address inside # <> are allowed, such as ) - if ((!$from) || (($from ne "<>") && ($from !~ - /^<([a-zA-Z0-9._%+-]+)\@(([a-zA-Z0-9-]+)\.)+([a-zA-Z]{2,4})>$/))) { - sendcontrol "501 Invalid address\r\n"; - } - else { + if (($from eq "<>") || + (!$smtputf8 && $from =~ + /^<([a-zA-Z0-9._%+-]+)\@(([a-zA-Z0-9-]+)\.)+([a-zA-Z]{2,4})>$/) || + ($smtputf8 && $from =~ + /^<([a-zA-Z0-9\x{80}-\x{ff}._%+-]+)\@(([a-zA-Z0-9\x{80}-\x{ff}-]+)\.)+([a-zA-Z]{2,4})>$/)) { my @found; my $valid = 1; @@ -852,6 +853,9 @@ sub MAIL_smtp { sendcontrol "250 Sender OK\r\n"; } } + else { + sendcontrol "501 Invalid address\r\n"; + } } return 0; -- cgit v1.2.3