about summary refs log tree commit
diff options
context:
space:
mode:
authorGraham Barr <gbarr@pobox.com>2004-09-27 10:32:01 +0000
committerGraham Barr <gbarr@pobox.com>2009-02-24 10:40:46 -0600
commit3b3fad04dcc7e4ebfa1bc42e39916c6dd14d0583 (patch)
tree40a6fe8a7830ebf8ad5b2d50f786734c0ed61c8f
parente61b2fcd411047254b761bc0858c61078d8b6c2f (diff)
downloadperl-libnet-3b3fad04dcc7e4ebfa1bc42e39916c6dd14d0583.tar.gz
Handle CRLF that cross a block boundary
-rw-r--r--Net/FTP/A.pm7
1 files changed, 5 insertions, 2 deletions
diff --git a/Net/FTP/A.pm b/Net/FTP/A.pm
index d068828..44b9cdb 100644
--- a/Net/FTP/A.pm
+++ b/Net/FTP/A.pm
@@ -10,7 +10,7 @@ use Carp;
 require Net::FTP::dataconn;
 
 @ISA = qw(Net::FTP::dataconn);
-$VERSION = "1.16";
+$VERSION = "1.17";
 
 sub read {
   my    $data          = shift;
@@ -71,7 +71,10 @@ sub write {
   my    $size         = shift || croak 'write($buf,$size,[$timeout])';
   my    $timeout = @_ ? shift : $data->timeout;
 
-  (my $tmp = substr($buf,0,$size)) =~ s/\r?\n/\015\012/sg;
+  my $nr = (my $tmp = substr($buf,0,$size)) =~ tr/\r\n/\015\012/;
+  $tmp =~ s/[^\015]\012/\015\012/sg if $nr;
+  $tmp =~ s/^\012/\015\012/ unless ${*$data}{'net_ftp_outcr'};
+  ${*$data}{'net_ftp_outcr'} = substr($tmp,-1) eq "\015";
 
   # If the remote server has closed the connection we will be signal'd
   # when we write. This can happen if the disk on the remote server fills up