Further refactor when an extra endline is added with the FORCEDENDLINE option

This commit is contained in:
Griatch 2018-01-29 20:03:54 +01:00
parent 9d34cd9956
commit 3a3f2bfe9e
2 changed files with 4 additions and 5 deletions

View file

@ -234,12 +234,10 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
# escape IAC in line mode, and correctly add \r\n (the TELNET end-of-line)
line = line.replace(IAC, IAC + IAC)
line = line.replace('\n', '\r\n')
if not self.protocol_flags.get("NOGOAHEAD", True):
if self.protocol_flags.get("FORCEDENDLINE", False):
line += "\r\n"
line += IAC + GA
elif not line.endswith("\r\n"):
if not line.endswith("\r\n") and self.protocol_flags.get("FORCEDENDLINE", True):
line += "\r\n"
if not self.protocol_flags.get("NOGOAHEAD", True):
line += IAC + GA
return self.transport.write(mccp_compress(self, line))
# Session hooks

View file

@ -113,6 +113,7 @@ class Ttype(object):
# only support after a certain version, but all support
# it since at least 4 years. We assume recent client here for now.
cupper = clientname.upper()
xterm256 = False
if cupper.startswith("MUDLET"):
# supports xterm256 stably since 1.1 (2010?)
xterm256 = cupper.split("MUDLET", 1)[1].strip() >= "1.1"