diff options
author | jeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-30 11:23:15 +0000 |
---|---|---|
committer | jeg2 <jeg2@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-30 11:23:15 +0000 |
commit | 0fc23bda529a9c8072eaee7db103f679aafa37b8 (patch) | |
tree | 4ce6788a048d14a7c4a063a4eeb7e86ddb2fa7f2 | |
parent | cd8aabdafae01d0dfa6ab84f200331281ac15773 (diff) |
Merged 16241 from trunk.
* 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: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | lib/net/telnet.rb | 13 |
2 files changed, 18 insertions, 3 deletions
@@ -1,3 +1,11 @@ +Wed Apr 30 20:22:40 2008 James Edward Gray II <[email protected]> + + Merged 16241 from trunk. + + * 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. + Wed Apr 30 17:47:21 2008 Nobuyoshi Nakada <[email protected]> * re.c (rb_reg_search): use local variable. a patch from wanabe diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb index 80b95a5149..a55527f15e 100644 --- a/lib/net/telnet.rb +++ b/lib/net/telnet.rb @@ -559,7 +559,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 @@ -571,9 +572,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 |