Merge branch 'master' into develop

This commit is contained in:
Griatch 2021-05-09 15:43:39 +02:00
commit 64712f704d
4 changed files with 14 additions and 7 deletions

View file

@ -40,6 +40,9 @@ class SuppressGA(object):
self.protocol = protocol
self.protocol.protocol_flags["NOGOAHEAD"] = True
self.protocol.protocol_flags[
"NOPROMPTGOAHEAD"
] = True # Used to send a GA after a prompt line only, set in TTYPE (per client)
# tell the client that we prefer to suppress GA ...
self.protocol.will(SUPPRESS_GA).addCallbacks(self.will_suppress_ga, self.wont_suppress_ga)

View file

@ -442,7 +442,9 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, _BASE_SESSION_CLASS):
prompt = mxp_parse(prompt)
prompt = to_bytes(prompt, self)
prompt = prompt.replace(IAC, IAC + IAC).replace(b"\n", b"\r\n")
prompt += IAC + GA
if not self.protocol_flags.get("NOPROMPTGOAHEAD",
self.protocol_flags.get("NOGOAHEAD", True)):
prompt += IAC + GA
self.transport.write(mccp_compress(self, prompt))
else:
if echo is not None:

View file

@ -231,7 +231,6 @@ class TestTelnet(TwistedTestCase):
self.transport.client = ["localhost"]
self.transport.setTcpKeepAlive = Mock()
d = self.proto.makeConnection(self.transport)
# test suppress_ga
self.assertTrue(self.proto.protocol_flags["NOGOAHEAD"])
self.proto.dataReceived(IAC + DONT + SUPPRESS_GA)
@ -246,13 +245,15 @@ class TestTelnet(TwistedTestCase):
self.assertEqual(self.proto.protocol_flags["SCREENHEIGHT"][0], 45)
self.assertEqual(self.proto.handshakes, 6)
# test ttype
self.assertTrue(self.proto.protocol_flags["FORCEDENDLINE"])
self.assertFalse(self.proto.protocol_flags["TTYPE"])
self.assertTrue(self.proto.protocol_flags["ANSI"])
self.proto.dataReceived(IAC + WILL + TTYPE)
self.proto.dataReceived(b"".join([IAC, SB, TTYPE, IS, b"MUDLET", IAC, SE]))
self.assertTrue(self.proto.protocol_flags["XTERM256"])
self.assertEqual(self.proto.protocol_flags["CLIENTNAME"], "MUDLET")
self.assertTrue(self.proto.protocol_flags["FORCEDENDLINE"])
self.assertTrue(self.proto.protocol_flags["NOGOAHEAD"])
self.assertFalse(self.proto.protocol_flags["NOPROMPTGOAHEAD"])
self.proto.dataReceived(b"".join([IAC, SB, TTYPE, IS, b"XTERM", IAC, SE]))
self.proto.dataReceived(b"".join([IAC, SB, TTYPE, IS, b"MTTS 137", IAC, SE]))
self.assertEqual(self.proto.handshakes, 5)

View file

@ -119,10 +119,11 @@ class Ttype(object):
if clientname.startswith("MUDLET"):
# supports xterm256 stably since 1.1 (2010?)
xterm256 = clientname.split("MUDLET", 1)[1].strip() >= "1.1"
self.protocol.protocol_flags["FORCEDENDLINE"] = False
if clientname.startswith("TINTIN++"):
self.protocol.protocol_flags["FORCEDENDLINE"] = True
# Mudlet likes GA's on a prompt line for the prompt trigger to
# match, if it's not wanting NOGOAHEAD.
if not self.protocol.protocol_flags["NOGOAHEAD"]:
self.protocol.protocol_flags["NOGOAHEAD"] = True
self.protocol.protocol_flags["NOPROMPTGOAHEAD"] = False
if (
clientname.startswith("XTERM")