diff --git a/src/server/serversession.py b/src/server/serversession.py index eab3b706ad..5e4132cdea 100644 --- a/src/server/serversession.py +++ b/src/server/serversession.py @@ -13,7 +13,7 @@ from django.conf import settings #from src.scripts.models import ScriptDB from src.comms.models import ChannelDB from src.utils import logger, utils -from src.utils.utils import make_iter, to_unicode, to_str, escape_control_sequences +from src.utils.utils import make_iter from src.commands.cmdhandler import cmdhandler from src.commands.cmdsethandler import CmdSetHandler from src.server.session import Session @@ -198,7 +198,7 @@ class ServerSession(Session): """ if text: # this is treated as a command input - text = to_unicode(escape_control_sequences(text), encoding=self.encoding) + #text = to_unicode(escape_control_sequences(text), encoding=self.encoding) # handle the 'idle' command if text.strip() == IDLE_COMMAND: self.update_session_counters(idle=True) @@ -231,11 +231,12 @@ class ServerSession(Session): """ Send Evennia -> User """ - if text is None: - text = "" - else: - text = to_unicode(text) - text = to_str(text, self.encoding) + text = text if text else "" + #if text is None: + # text = "" + #else: + # text = to_unicode(text) + # text = to_str(text, self.encoding) self.sessionhandler.data_out(self, text=text, **kwargs) diff --git a/src/server/sessionhandler.py b/src/server/sessionhandler.py index 196125546a..d4498054f1 100644 --- a/src/server/sessionhandler.py +++ b/src/server/sessionhandler.py @@ -15,7 +15,8 @@ There are two similar but separate stores of sessions: import time from django.conf import settings from src.commands.cmdhandler import CMD_LOGINSTART -from src.utils.utils import variable_from_module, is_iter +from src.utils.utils import variable_from_module, is_iter, \ + to_str, to_unicode, strip_control_sequences try: import cPickle as pickle except ImportError: @@ -469,6 +470,7 @@ class ServerSessionHandler(SessionHandler): """ Sending data Server -> Portal """ + text = text and to_str(to_unicode(text), encoding=session.encoding) self.server.amp_protocol.call_remote_MsgServer2Portal(sessid=session.sessid, msg=text, data=kwargs) @@ -479,6 +481,7 @@ class ServerSessionHandler(SessionHandler): """ session = self.sessions.get(sessid, None) if session: + text = text and to_unicode(strip_control_sequences(text), encoding=session.encoding) session.data_in(text=text, **kwargs) SESSIONS = ServerSessionHandler() diff --git a/src/utils/utils.py b/src/utils/utils.py index 8be0eb73dd..c6025c1620 100644 --- a/src/utils/utils.py +++ b/src/utils/utils.py @@ -1105,7 +1105,7 @@ class lazy_property(object): _STRIP_ANSI = None _RE_CONTROL_CHAR = re.compile('[%s]' % re.escape(''.join([unichr(c) for c in range(0,32)])))# + range(127,160)]))) -def escape_control_sequences(string): +def strip_control_sequences(string): """ remove non-print text sequences from string. """