On Jan 30, 2008 at 18:50:39 -0600, Graham Barr wrote:
Show quoted text> On Jan 30, 2008, at 2:48 PM, Aidan Van Dyk via RT wrote:
> > Here's a patch t fix it:
>
> Nothing like being polite :-)
>
> It would help if you described what problem you had.
He was replying to the original issue on RT #20082 -- Net::FTP doesn't
appear to implement a fully RFC-compliant STOU. Based on the discussion
I had with Aidan today, he seems to have independently discovered the
problem described by the original reporter.
The reason I'm jumping in here is because I'm the one who convinced
Aidan that rather than sitting on a private patch that fixes this bug he
should be nice and feed it back to the community, especially when it
fixes an RFC-compliance issue that's been an open ticket (albeit a
poorly explained one) for over a year.
Show quoted text> $remote will default to the local name and is only required if send a
> stream and there is a check for that case.
According to RFC 959, STOU should never have a remote filename argument.
The command should be STOU<CRLF> and shouldn't default to the local
filename at all, as the server generates the filename and returns it.
Here's the problem in detail. This is what you'd expect to do to send a
STOU:
my $local_filename = '/tmp/whatever';
$ftp->put_unique( $local_filename )
But, this will default $remote to the local filename, and send:
"STOU /tmp/whatever\015\012"
to the remote server. This will fail, because STOU doesn't take an
argument.
Since the code checks for undef, the obvious workaround is to try
providing a blank remote filename:
my $local_filename = '/tmp/whatever';
$ftp->put_unique( $local_filename, '' )
It does work around the default assignation of the local filename to
$remote. Unfortunately, it does generate a broken command:
"STOU \015\012"
The trailing space after the STOU can cause some FTP servers to reject
it as invalid.
Show quoted text> your patch could also result in a stor command being sent with no name.
It shouldn't do so -- $ftp->_need_name($cmd) will only return a false
value iff $cmd is STOU, so the $remote name should always default to the
local one for a STOR.
Please reopen the ticket and apply his patch for the next release.
Thanks,
Dave