mirror of
https://github.com/evennia/evennia.git
synced 2026-03-18 22:06:30 +01:00
Added escaping of unicode text input of ASCII control characters and extended characters as per #551.
This commit is contained in:
parent
8afdbc6adb
commit
4e2dfef321
2 changed files with 9 additions and 2 deletions
|
|
@ -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
|
||||
from src.utils.utils import make_iter, to_unicode, escape_control_sequences
|
||||
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(text)
|
||||
text = to_unicode(escape_control_sequences(text))
|
||||
# handle the 'idle' command
|
||||
if text.strip() == IDLE_COMMAND:
|
||||
self.update_session_counters(idle=True)
|
||||
|
|
|
|||
|
|
@ -1095,3 +1095,10 @@ class lazy_property(object):
|
|||
value = self.func(obj)
|
||||
obj.__dict__[self.__name__] = value
|
||||
return value
|
||||
|
||||
_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):
|
||||
"""
|
||||
remove non-print text sequences from string.
|
||||
"""
|
||||
return _RE_CONTROL_CHAR.sub('', string)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue