diff options
author | Graham Barr <gbarr@pobox.com> | 2008-02-09 15:50:45 +0000 |
---|---|---|
committer | Graham Barr <gbarr@pobox.com> | 2009-02-24 10:40:49 -0600 |
commit | cd6f1d18524cbbda5c2f7ca4e338ac1f2be45f8e (patch) | |
tree | 6954dcacd404e6c2979d79beff346810fa4a7817 | |
parent | bfe2293506e09473dda75804fd51e6e009979f8d (diff) | |
download | perl-libnet-cd6f1d18524cbbda5c2f7ca4e338ac1f2be45f8e.tar.gz |
Encode . as .. when datasend is called with a buffer that starts with \012. and
the previous buffer ended with \015
-rw-r--r-- | Net/Cmd.pm | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -37,7 +37,7 @@ BEGIN { } } -$VERSION = "2.29"; +$VERSION = "2.29_1"; @ISA = qw(Exporter); @EXPORT = qw(CMD_INFO CMD_OK CMD_MORE CMD_REJECT CMD_ERROR CMD_PENDING); @@ -406,6 +406,8 @@ sub datasend { return 0 unless defined(fileno($cmd)); my $last_ch = ${*$cmd}{'net_cmd_last_ch'}; + + # We have not send anything yet, so last_ch = "\012" means we are at the start of a line $last_ch = ${*$cmd}{'net_cmd_last_ch'} = "\012" unless defined $last_ch; return 1 unless length $line; @@ -421,9 +423,13 @@ sub datasend { my $first_ch = ''; if ($last_ch eq "\015") { - $first_ch = "\012" if $line =~ s/^\012//; + # Remove \012 so it does not get prefixed with another \015 below + # and escape the . if there is one following it because the fixup + # below will not find it + $first_ch = "\012" if $line =~ s/^\012(\.?)/$1$1/; } elsif ($last_ch eq "\012") { + # Fixup below will not find the . as the first character of the buffer $first_ch = "." if $line =~ /^\./; } |