Support clients using CR+NUL to signal EOL
[mudpy.git] / mudpy / misc.py
index bae94b6..4e43353 100644 (file)
@@ -843,11 +843,15 @@ class User:
             mudpy.telnet.negotiate_telnet_options(self)
 
             # separate multiple input lines
-            new_input_lines = self.partial_input.split(b"\n")
+            new_input_lines = self.partial_input.split(b"\r\0")
+            if len(new_input_lines) == 1:
+                new_input_lines = new_input_lines[0].split(b"\r\n")
 
             # if input doesn't end in a newline, replace the
             # held partial input with the last line of it
-            if not self.partial_input.endswith(b"\n"):
+            if not (
+                    self.partial_input.endswith(b"\r\0") or
+                    self.partial_input.endswith(b"\r\n")):
                 self.partial_input = new_input_lines.pop()
 
             # otherwise, chop off the extra null input and reset