1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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/trunk@16241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
jeg2 2008-04-30 11:14:52 +00:00
parent 01b773a093
commit e1bc480e98
2 changed files with 16 additions and 3 deletions

View file

@ -1,3 +1,9 @@
Wed Apr 30 20:11:36 2008 James Edward Gray II <jeg2@ruby-lang.org>
* 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@ruby-lang.org> Wed Apr 30 18:03:01 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* load.c (rb_load_path), vm_core.h (rb_vm_t): moved to VM. * load.c (rb_load_path), vm_core.h (rb_vm_t): moved to VM.

View file

@ -562,7 +562,8 @@ module Net
Integer(c.rindex(/#{IAC}#{SB}/no)) Integer(c.rindex(/#{IAC}#{SB}/no))
buf = preprocess(c[0 ... c.rindex(/#{IAC}#{SB}/no)]) buf = preprocess(c[0 ... c.rindex(/#{IAC}#{SB}/no)])
rest = c[c.rindex(/#{IAC}#{SB}/no) .. -1] 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]) buf = preprocess(c[0 ... pt])
rest = c[pt .. -1] rest = c[pt .. -1]
else else
@ -574,9 +575,15 @@ module Net
# #
# We cannot use preprocess() on this data, because that # We cannot use preprocess() on this data, because that
# method makes some Telnetmode-specific assumptions. # method makes some Telnetmode-specific assumptions.
buf = c buf = rest + c
buf.gsub!(/#{EOL}/no, "\n") unless @options["Binmode"]
rest = '' 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 end
@log.print(buf) if @options.has_key?("Output_log") @log.print(buf) if @options.has_key?("Output_log")
line += buf line += buf