summaryrefslogtreecommitdiffstats
path: root/lib/net
diff options
context:
space:
mode:
authorjeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-30 11:14:52 +0000
committerjeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-04-30 11:14:52 +0000
commit59e655c25614a66e90e5745f7f3bbdea78f6b963 (patch)
tree55e99644732d68b169a5a2a996eef194bafe70e1 /lib/net
parent0ad5a9cb07a670d84c58bac2f2af3dbd5c039ee3 (diff)
downloadruby-59e655c25614a66e90e5745f7f3bbdea78f6b963.tar.gz
ruby-59e655c25614a66e90e5745f7f3bbdea78f6b963.tar.xz
ruby-59e655c25614a66e90e5745f7f3bbdea78f6b963.zip
* lib/net/telnet.rb: Fixing a bug where line endings would not be properly
escaped when the two character ending was broken up into separate TCP packets. Issue reported and patched by Brian Candler. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net')
-rw-r--r--lib/net/telnet.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb
index dfbe932dc..1d38ee91f 100644
--- a/lib/net/telnet.rb
+++ b/lib/net/telnet.rb
@@ -562,7 +562,8 @@ module Net
Integer(c.rindex(/#{IAC}#{SB}/no))
buf = preprocess(c[0 ... c.rindex(/#{IAC}#{SB}/no)])
rest = c[c.rindex(/#{IAC}#{SB}/no) .. -1]
- elsif pt = c.rindex(/#{IAC}[^#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]?\z/no)
+ elsif pt = c.rindex(/#{IAC}[^#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]?\z/no) ||
+ c.rindex(/\r\z/no)
buf = preprocess(c[0 ... pt])
rest = c[pt .. -1]
else
@@ -574,9 +575,15 @@ module Net
#
# We cannot use preprocess() on this data, because that
# method makes some Telnetmode-specific assumptions.
- buf = c
- buf.gsub!(/#{EOL}/no, "\n") unless @options["Binmode"]
+ buf = rest + c
rest = ''
+ unless @options["Binmode"]
+ if pt = buf.rindex(/\r\z/no)
+ buf = buf[0 ... pt]
+ rest = buf[pt .. -1]
+ end
+ buf.gsub!(/#{EOL}/no, "\n")
+ end
end
@log.print(buf) if @options.has_key?("Output_log")
line += buf