Add extended encoding message validation
- validates variables of the "message" type
This commit is contained in:
parent
e76b10a6ed
commit
7cc0f8fab0
|
@ -1,13 +1,21 @@
|
||||||
from debug import logger
|
from debug import logger
|
||||||
from messagetypes import MsgBase
|
from messagetypes import MsgBase
|
||||||
|
|
||||||
|
|
||||||
class Message(MsgBase):
|
class Message(MsgBase):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
return
|
return
|
||||||
|
|
||||||
def decode(self, data):
|
def decode(self, data):
|
||||||
self.subject = data["subject"]
|
# UTF-8 and variable type validator
|
||||||
self.body = data["body"]
|
if type(data["subject"]) is str:
|
||||||
|
self.subject = unicode(data["subject"], 'utf-8', 'replace')
|
||||||
|
else:
|
||||||
|
self.subject = unicode(str(data["subject"]), 'utf-8', 'replace')
|
||||||
|
if type(data["body"]) is str:
|
||||||
|
self.body = unicode(data["body"], 'utf-8', 'replace')
|
||||||
|
else:
|
||||||
|
self.body = unicode(str(data["body"]), 'utf-8', 'replace')
|
||||||
|
|
||||||
def encode(self, data):
|
def encode(self, data):
|
||||||
super(Message, self).encode()
|
super(Message, self).encode()
|
||||||
|
|
Reference in New Issue
Block a user