Added a validation-check when changing encodings using the default commands (unloggedin/general). Also put in a safety catch in the sessionhandler to reset faulty encodings that slips by for some reason. This can otherwise lead to errors for shutting down the server since the server fails trying to inform the faulty session about the shutdown.

This commit is contained in:
Griatch 2016-01-12 21:35:27 +01:00
parent 33c479fe04
commit 5d6d13bb12
3 changed files with 22 additions and 5 deletions

View file

@ -524,7 +524,13 @@ class ServerSessionHandler(SessionHandler):
#from evennia.server.profiling.timetrace import timetrace
#text = timetrace(text, "ServerSessionHandler.data_out")
text = text and to_str(to_unicode(text), encoding=session.encoding)
try:
text = text and to_str(to_unicode(text), encoding=session.encoding)
except LookupError:
# wrong encoding set on the session. Set it to a safe one
session.encoding = "utf-8"
text = to_str(to_unicode(text), encoding=session.encoding)
# send across AMP
self.server.amp_protocol.send_MsgServer2Portal(session,