mirror of
https://github.com/evennia/evennia.git
synced 2026-03-30 12:37:16 +02:00
Make sure player input is valid unicode. If an un-decodable character is encountered, replace it with question marks. We'll need to test this with a more unicode capable client than I have.
This commit is contained in:
parent
b57608cf55
commit
af19724bb2
2 changed files with 14 additions and 4 deletions
|
|
@ -133,7 +133,9 @@ class Command(object):
|
|||
"""
|
||||
Instantiates the Command object and does some preliminary parsing.
|
||||
"""
|
||||
self.raw_input = raw_input
|
||||
# If we get a unicode string with un-recognizable characters, replace
|
||||
# them instead of throwing errors.
|
||||
self.raw_input = unicode(raw_input, errors='replace')
|
||||
self.source_object = source_object
|
||||
self.session = session
|
||||
# The work starts here.
|
||||
|
|
@ -441,7 +443,8 @@ def handle(command, ignore_state=False):
|
|||
# Nothing sent in of value, ignore it.
|
||||
raise ExitCommandHandler
|
||||
|
||||
state = None #no state by default
|
||||
# No state by default.
|
||||
state = None
|
||||
|
||||
if command.session and not command.session.logged_in:
|
||||
# Not logged in, look through the unlogged-in command table.
|
||||
|
|
|
|||
|
|
@ -47,6 +47,10 @@ class SessionProtocol(StatefulTelnetProtocol):
|
|||
self.address = self.getClientAddress()
|
||||
self.name = None
|
||||
self.uid = None
|
||||
# This is merely here to serve as a convenient reference. It is not
|
||||
# necessarily the most up to date version of the object, so it is NOT
|
||||
# safe to look at pobject's location or any other attributes from
|
||||
# the Object model.
|
||||
self.pobject = None
|
||||
self.logged_in = False
|
||||
# The time the user last issued a command.
|
||||
|
|
@ -78,9 +82,12 @@ class SessionProtocol(StatefulTelnetProtocol):
|
|||
Any line return indicates a command for the purpose of a MUD. So we take
|
||||
the user input and pass it to this session's pobject.
|
||||
"""
|
||||
if self.pobject:
|
||||
if self.is_loggedin():
|
||||
# Session is logged in, run through the normal object execution.
|
||||
self.pobject.execute_cmd(data, session=self)
|
||||
# Get the most up to date copy of the Object.
|
||||
pobject = self.get_pobject()
|
||||
if pobject:
|
||||
pobject.execute_cmd(data, session=self)
|
||||
else:
|
||||
# Not logged in, manually execute the command.
|
||||
cmdhandler.handle(cmdhandler.Command(None, data, session=self))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue