summaryrefslogtreecommitdiff
path: root/tests/ftpserver.pl
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-09-29 09:53:49 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-09-29 10:02:00 +0100
commit49341628b50007c290d669ce3f51c562aad9708c (patch)
tree5b8030e7257434a7d75a0d548906ad62f3e3d5d6 /tests/ftpserver.pl
parentab7e6afd44f1b447b8d6546ca351e858d2784ac5 (diff)
downloadgnurl-49341628b50007c290d669ce3f51c562aad9708c.tar.gz
gnurl-49341628b50007c290d669ce3f51c562aad9708c.tar.bz2
gnurl-49341628b50007c290d669ce3f51c562aad9708c.zip
ftpserver.pl: Moved specifying the test number from the RCPT address
...to the client address as this frees the RCPT strings to contain just an email address and by passing the test number into curl as the client address remains consistent with POP3 and IMAP tests as they are specified in the URL.
Diffstat (limited to 'tests/ftpserver.pl')
-rwxr-xr-xtests/ftpserver.pl24
1 files changed, 15 insertions, 9 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index 838d849a0..907846ab9 100755
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -685,12 +685,12 @@ sub close_dataconn {
################ SMTP commands
################
-# what set by "RCPT"
-my $smtp_rcpt;
-
# The type of server (SMTP or ESMTP)
my $smtp_type;
+# The client (which normally contains the test number)
+my $smtp_client;
+
sub EHLO_smtp {
my ($client) = @_;
@@ -753,6 +753,9 @@ sub EHLO_smtp {
sendcontrol "250 $d\r\n";
}
}
+
+ # Store the client (as it may contain the test number)
+ $smtp_client = $client;
}
return 0;
@@ -784,6 +787,9 @@ sub HELO_smtp {
# Send the HELO response
sendcontrol "250 $smtp_type pingpong test server Hello $client\r\n";
+
+ # Store the client (as it may contain the test number)
+ $smtp_client = $client;
}
return 0;
@@ -854,11 +860,11 @@ sub RCPT_smtp {
sendcontrol "501 Unrecognized parameter\r\n";
}
else {
- $smtp_rcpt = $1;
+ my $to = $1;
# Validate the to address (only a valid email address inside <> is
# allowed, such as <user@example.com>)
- if ($smtp_rcpt !~
+ if ($to !~
/^<([a-zA-Z0-9._%+-]+)\@([a-zA-Z0-9.-]+).([a-zA-Z]{2,4})>$/) {
sendcontrol "501 Invalid address\r\n";
}
@@ -872,17 +878,17 @@ sub RCPT_smtp {
sub DATA_smtp {
my ($args) = @_;
- my $testno = $smtp_rcpt;
if ($args) {
sendcontrol "501 Unrecognized parameter\r\n";
}
+ elsif ($smtp_client !~ /^(\d*)$/)
+ sendcontrol "501 Invalid arguments\r\n";
+ }
else {
- $testno =~ s/^([^0-9]*)([0-9]+).*/$2/;
sendcontrol "354 Show me the mail\r\n";
- logmsg "===> rcpt $testno was $smtp_rcpt\n";
-
+ my $testno = $smtp_client;
my $filename = "log/upload.$testno";
logmsg "Store test number $testno in $filename\n";