Fixed a bug in telnet protocol that stripped wrong characters at the end. Resolves Issue 318.

This commit is contained in:
Griatch 2012-10-28 10:37:14 +01:00
parent 58533165eb
commit ee7a175bf4
2 changed files with 14 additions and 4 deletions

View file

@ -202,10 +202,17 @@ class CmdSet(object):
Returns a new cmdset with the same settings as this one Returns a new cmdset with the same settings as this one
(no actual commands are copied over) (no actual commands are copied over)
""" """
cmdset = self.__class__() cmdset = CmdSet()
cmdset.__dict__.update(dict((key, val) for key, val in self.__dict__.items() if key in self.to_duplicate)) for key, val in ((key, getattr(self, key)) for key in self.to_duplicate):
cmdset.key_mergetypes = self.key_mergetypes.copy() #copy.deepcopy(self.key_mergetypes) if val != getattr(cmdset, key):
# only copy if different from default; avoid turning class-vars into instance vars
setattr(cmdset, key, val)
cmdset.key_mergetypes = self.key_mergetypes.copy()
return cmdset return cmdset
#cmdset = self.__class__()
#cmdset.__dict__.update(dict((key, val) for key, val in self.__dict__.items() if key in self.to_duplicate))
#cmdset.key_mergetypes = self.key_mergetypes.copy() #copy.deepcopy(self.key_mergetypes)
#return cmdset
def __str__(self): def __str__(self):
""" """

View file

@ -7,12 +7,15 @@ sessions etc.
""" """
import re
from twisted.conch.telnet import Telnet, StatefulTelnetProtocol, IAC, LINEMODE from twisted.conch.telnet import Telnet, StatefulTelnetProtocol, IAC, LINEMODE
from src.server.session import Session from src.server.session import Session
from src.server import ttype, mssp from src.server import ttype, mssp
from src.server.mccp import Mccp, mccp_compress, MCCP from src.server.mccp import Mccp, mccp_compress, MCCP
from src.utils import utils, ansi, logger from src.utils import utils, ansi, logger
_RE_N = re.compile(r"\{n$")
class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session): class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
""" """
Each player connecting over telnet (ie using most traditional mud Each player connecting over telnet (ie using most traditional mud
@ -163,4 +166,4 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
self.sendLine(string) self.sendLine(string)
else: else:
# we need to make sure to kill the color at the end in order to match the webclient output. # we need to make sure to kill the color at the end in order to match the webclient output.
self.sendLine(ansi.parse_ansi(string.rstrip("{n") + "{n", strip_ansi=nomarkup, xterm256=ttype.get('256 COLORS'))) self.sendLine(ansi.parse_ansi(_RE_N.sub("", string) + "{n", strip_ansi=nomarkup, xterm256=ttype.get('256 COLORS')))