Subject: | Net::FTP rmdir($path, 1) - infinite loop on bad ftp servers |
Hello.
Some ftp servers give strange output on $ftp->ls().
Ff $ftp->ls() gives listing like that:
dir/dir1/.
dir/dir1/..
dir/dir1/file
rmdir falls into infinite loop deleting dir/dir1/., dir/dir1/./. etc.
diff below shows where the problem is.
*** /usr/lib/perl5/5.10.1/Net/FTP.pm 2007-08-26 16:14:12.000000000
+0400
--- /usr/lib/perl5/5.10.1/Net/FTP1.pm 2010-01-13 13:59:10.000000000
+0300
***************
*** 578,584 ****
# Try to delete the contents
# Get a list of all the files in the directory
! my @filelist = grep { !/^\.{1,2}$/ } $ftp->ls($dir);
return undef
unless @filelist; # failed, it is probably not a directory
--- 578,584 ----
# Try to delete the contents
# Get a list of all the files in the directory
! my @filelist = grep { !/^\.{1,2}$/ && !/\/\.{1,2}$/ } $ftp->ls
($dir);
return undef
unless @filelist; # failed, it is probably not a directory
Thanks.