If the client does not have binary send enabled per prior Telnet
option negotiation, filter for non-ASCII characters. This fixes a
bug where previously only binary mode senders were checked for
non-ASCII input and 7-bit senders were checked for non-UTF-8 input
rather than the other way around.
line = line.strip()
# log non-printable characters remaining
- if mudpy.telnet.is_enabled(self, mudpy.telnet.TELOPT_BINARY,
- mudpy.telnet.HIM):
+ if not mudpy.telnet.is_enabled(
+ self, mudpy.telnet.TELOPT_BINARY, mudpy.telnet.HIM):
asciiline = bytes([x for x in line if 32 <= x <= 126])
if line != asciiline:
logline = "Non-ASCII characters from "
test_telnet_iac = (
# Send a double (escaped) IAC byte within other text, which should get
# unescaped and deduplicated to a single \xff in the buffer and then
- # the line of input discarded as a non-UTF-8 sequence
+ # the line of input discarded as a non-ASCII sequence
(2, "> ", b"say argle\xff\xffbargle\r\n"),
- (2, r"Non-UTF-8 sequence from admin: b'say argle\\xffbargle'.*> ", ""),
+ (2, r"Non-ASCII characters from admin: b'say argle\\xffbargle'.*> ", ""),
)
test_telnet_unknown = (