Subject: | Filenames with special chars break ->dir_hashref |
Remote files with special (regex) characters in their names lead to
unexpected results when using $ftp->dir_hashref.
Assuming a directory containing a file named 'f(o)o' (without the quotes):
$ cat test.pl
#!/usr/bin/perl
use warnings;
use strict;
use Net::FTP::File;
use Data::Dumper;
$ftp = Net::FTP->new( '...' );
$ftp->login( '...', '...' );
print Dumper [$ftp->dir_hashref];
$ perl test.pl
Use of uninitialized value in substr at
/usr/local/share/perl/5.8.8/Net/FTP/File.pm line 50.
substr outside of string at /usr/local/share/perl/5.8.8/Net/FTP/File.pm
line 50.
Use of uninitialized value in split at
/usr/local/share/perl/5.8.8/Net/FTP/File.pm line 51.
Use of uninitialized value in hash element at
/usr/local/share/perl/5.8.8/Net/FTP/File.pm line 52.
Use of uninitialized value in hash element at
/usr/local/share/perl/5.8.8/Net/FTP/File.pm line 55.
Use of uninitialized value in hash element at
/usr/local/share/perl/5.8.8/Net/FTP/File.pm line 55.
Use of uninitialized value in hash element at
/usr/local/share/perl/5.8.8/Net/FTP/File.pm line 55.
Use of uninitialized value in hash element at
/usr/local/share/perl/5.8.8/Net/FTP/File.pm line 55.
Use of uninitialized value in hash element at
/usr/local/share/perl/5.8.8/Net/FTP/File.pm line 55.
Use of uninitialized value in hash element at
/usr/local/share/perl/5.8.8/Net/FTP/File.pm line 55.
Use of uninitialized value in hash element at
/usr/local/share/perl/5.8.8/Net/FTP/File.pm line 55.
Use of uninitialized value in hash element at
/usr/local/share/perl/5.8.8/Net/FTP/File.pm line 55.
Use of uninitialized value in hash element at
/usr/local/share/perl/5.8.8/Net/FTP/File.pm line 55.
$VAR1 = [
{
'' => {
'Bytes' => '0',
'Group' => 'fw',
'Owner' => 'fw',
'Path' => undef,
'Last Modified Year/Time' => '12:21',
'Permissions' => '-rw-r--r--',
'Last Modified Day' => '11',
'Link To' => undef,
'Number of Links' => '1',
'Last Modified Month' => 'Sep'
}
}
];
A patch is attached.
Thanks, Frank
Subject: | File.pm.patch |
--- File.pm.old 2008-09-11 14:38:13.000000000 +0200
+++ File.pm.new 2008-09-11 14:38:05.000000000 +0200
@@ -43,7 +43,7 @@
my @parts = split /\s+/, $line;
my @lin = split /\s/, $line;
- my $path_re = join '\s+', @parts[8 .. $#parts];
+ my $path_re = join '\s+', map { quotemeta } @parts[8 .. $#parts];
$path_re = '\s*' . $path_re . '\s*';
$path_re = qr($path_re);
my ($path) = $line =~ m{($path_re)};