ruby-changes:4747
From: ko1@a...
Date: Wed, 30 Apr 2008 20:15:05 +0900 (JST)
Subject: [ruby-changes:4747] jeg2 - Ruby:r16241 (trunk): * lib/net/telnet.rb: Fixing a bug where line endings would not be properly
jeg2 2008-04-30 20:14:52 +0900 (Wed, 30 Apr 2008) New Revision: 16241 Modified files: trunk/ChangeLog trunk/lib/net/telnet.rb Log: * 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. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16241&r2=16240&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/net/telnet.rb?r1=16241&r2=16240&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 16240) +++ ChangeLog (revision 16241) @@ -1,3 +1,9 @@ +Wed Apr 30 20:11:36 2008 James Edward Gray II <jeg2@r...> + + * 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 18:03:01 2008 Nobuyoshi Nakada <nobu@r...> * load.c (rb_load_path), vm_core.h (rb_vm_t): moved to VM. Index: lib/net/telnet.rb =================================================================== --- lib/net/telnet.rb (revision 16240) +++ lib/net/telnet.rb (revision 16241) @@ -562,7 +562,8 @@ 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 @@ # # 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/