diff options
author | Steve Holme <steve_holme@hotmail.com> | 2013-09-22 15:05:43 +0100 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2013-09-22 15:05:43 +0100 |
commit | 8880f84e1a8f9642b883e429588e26f928711245 (patch) | |
tree | 33dae0010587110fb4efc74d3750f2e0c2072082 /tests/ftpserver.pl | |
parent | 9d4a8c7936401ef76fac89d4888d26cac12e3a80 (diff) | |
download | curl-8880f84e1a8f9642b883e429588e26f928711245.tar.gz |
ftpserver.pl: Expanded the SMTP RCPT handler to validate TO addresses
RCPT_smtp() will now check for a correctly formatted TO address which
allows for invalid recipient addresses to be added.
Diffstat (limited to 'tests/ftpserver.pl')
-rwxr-xr-x | tests/ftpserver.pl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index 588f98d5d..be2d545ba 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -849,13 +849,22 @@ sub RCPT_smtp { logmsg "RCPT_smtp got $args\n"; + # Get the TO parameter if($args !~ /^TO:(.*)/) { sendcontrol "501 Unrecognized parameter\r\n"; } else { $smtp_rcpt = $1; - sendcontrol "250 Recipient OK\r\n"; + # Validate the to address (only a valid email address inside <> is + # allowed, such as <user@example.com>) + if ($smtp_rcpt !~ + /^<([a-zA-Z0-9._%+-]+)\@([a-zA-Z0-9.-]+).([a-zA-Z]{2,4})>$/) { + sendcontrol "501 Invalid address\r\n"; + } + else { + sendcontrol "250 Recipient OK\r\n"; + } } return 0; |