Skip Menu |

This queue is for tickets about the libnet CPAN distribution.

Report information
The Basics
Id: 20663
Status: resolved
Priority: 0/
Queue: libnet

People
Owner: Nobody in particular
Requestors: kirk.zulsdorf [...] asgardwealthsolutions.com.au
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.19
Fixed in: (no value)



Subject: The dir method does not work if the directory has spaces.
Example code follows: #! /usr/bin/perl use Net::FTP; $ftp = Net::FTP->new("localhost", Debug => 9) or die "Cannot connect to localhost: $@"; $ftp->login("username",'password') or die "Cannot login ", $ftp->message; $dir="/dir with spaces"; print "\$FTP->LS\n"; print join("\n",$ftp->ls($dir)),"\n"; print "\$FTP->DIR\n"; print join("\n",$ftp->dir($dir)),"\n"; $ftp->quit; In the above example, the ls method returns a list of files. The dir method returns a NULL result. This occurs with libnet-1.19. Perl details: perl -V Summary of my perl5 (revision 5.0 version 8 subversion 3) configuration: Platform: osname=solaris, osvers=2.8, archname=sun4-solaris uname='sunos peruxas7 5.8 generic_108528-23 sun4u sparc sunw,sun- fire-v240 ' config_args='-de' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-fno-strict-aliasing -I/usr/local/include - D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O', cppflags='-fno-strict-aliasing -I/usr/local/include' ccversion='', gccversion='3.3.2', gccosandvers='solaris2.8' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='gcc', ldflags =' -L/usr/local/lib ' libpth=/usr/local/lib /usr/lib /usr/ccs/lib libs=-lsocket -lnsl -ldl -lm -lc perllibs=-lsocket -lnsl -ldl -lm -lc libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: USE_LARGE_FILES Built under solaris Compiled at Feb 15 2004 11:34:07 @INC: /usr/local/lib/perl5/5.8.3/sun4-solaris /usr/local/lib/perl5/5.8.3 /usr/local/lib/perl5/site_perl/5.8.3/sun4-solaris /usr/local/lib/perl5/site_perl/5.8.3 /usr/local/lib/perl5/site_perl
FTP was never designed to handle spaces in pathnames, so many servers do not handle it. For example many servers implement LIST with /bin/ls but split on whitespace $FTP->LS Net::FTP=GLOB(0x1809a70)>>> PASV Net::FTP=GLOB(0x1809a70)<<< 227 Entering Passive Mode (127,0,0,1,254,86) Net::FTP=GLOB(0x1809a70)>>> NLST /tmp/foo bar Net::FTP=GLOB(0x1809a70)<<< 150 Accepted data connection Net::FTP=GLOB(0x1809a70)<<< 226 2 matches total xxx yyy $FTP->DIR Net::FTP=GLOB(0x1809a70)>>> PASV Net::FTP=GLOB(0x1809a70)<<< 227 Entering Passive Mode (127,0,0,1,67,236) Net::FTP=GLOB(0x1809a70)>>> LIST /tmp/foo bar Net::FTP=GLOB(0x1809a70)<<< 150 Accepted data connection Net::FTP=GLOB(0x1809a70)<<< 226-Options: -l Net::FTP=GLOB(0x1809a70)<<< 226 2 matches total -rw-r--r-- 1 gbarr wheel 2748 Feb 9 07:33 /tmp/foo -rw-r--r-- 1 gbarr wheel 0 Feb 9 18:57 bar See that the response had two files not the directory expected. FTP does not have an escaping mechanism for paths, so there is nothing Net::FTP can do about this.