ftpserver.pl: Added the ability to include spaces in capabilities
authorSteve Holme <steve_holme@hotmail.com>
Sun, 15 Sep 2013 19:19:23 +0000 (20:19 +0100)
committerSteve Holme <steve_holme@hotmail.com>
Sun, 15 Sep 2013 19:56:16 +0000 (20:56 +0100)
For example:

CAPA "SIZE 1048576" 8BITMIME BINARYMIME

will populate the capabilities list with the following in:

SIZE 1048576
8BITMIME
BINARYMIME

tests/ftpserver.pl

index 74cf9f2..0975a20 100755 (executable)
@@ -2639,7 +2639,10 @@ sub customize {
         }
         elsif($_ =~ /CAPA (.*)/) {
             logmsg "FTPD: instructed to support CAPABILITY command\n";
-            @capabilities = split(/ /, $1);
+            @capabilities = split(/ (?!(?:[^" ]|[^"] [^"])+")/, $1);
+            foreach (@capabilities) {
+                $_ = $1 if /^"(.*)"$/;
+            }
         }
         elsif($_ =~ /AUTH (.*)/) {
             logmsg "FTPD: instructed to support AUTHENTICATION command\n";