about summary refs log tree commit
path: root/Net/Cmd.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Net/Cmd.pm')
-rw-r--r--Net/Cmd.pm10
1 files changed, 8 insertions, 2 deletions
diff --git a/Net/Cmd.pm b/Net/Cmd.pm
index 4f0e444..639a8a9 100644
--- a/Net/Cmd.pm
+++ b/Net/Cmd.pm
@@ -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 =~ /^\./;
   }