Fix message encoding bug

- prevent loading invalid message types
This commit is contained in:
Peter Šurda 2018-02-13 16:39:35 +01:00
parent 96ea36cfd2
commit 3a8016d31f
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
1 changed files with 4 additions and 3 deletions

View File

@ -12,9 +12,10 @@ class MsgBase(object):
def constructObject(data):
try:
classBase = eval(data[""] + "." + data[""].title())
except NameError:
logger.error("Don't know how to handle message type: \"%s\"", data[""])
m = import_module("messagetypes." + data[""])
classBase = getattr(m, data[""].title())
except (NameError, ImportError):
logger.error("Don't know how to handle message type: \"%s\"", data[""], exc_info=True)
return None
try:
returnObj = classBase()