Commit 14043bbf authored by Claudemir Todo Bom's avatar Claudemir Todo Bom

* junkreport: handle unknown character encodings

parent 9e3de6f5
Pipeline #176 passed with stage
in 1 minute and 29 seconds
......@@ -103,7 +103,10 @@ class MessageData(dict):
def processEnvelope(self, dataList):
dataDict = {}
dataDict["date"] = time.mktime(parsedate(dataList[0]))
if dataList[0] != None:
dataDict["date"] = time.mktime(parsedate(dataList[0]))
else:
dataDict["date"] = None;
dataDict["subject"] = wwMailUtils.decode_header(dataList[1])
dataDict["from"] = self.processAddressList(dataList[2])
dataDict["sender"] = self.processAddressList(dataList[3])
......@@ -188,7 +191,10 @@ class JunkReport:
for msgInfo in self.array.getData():
self.addHtmlTemplate(u"%(htmlboxon)s%(htmlpreon)s")
self.addTextTitleValue(u"Data/Hora", time.strftime("%c",time.localtime(msgInfo["imap.envelope"]["date"])))
if msgInfo["imap.envelope"]["date"] != None:
self.addTextTitleValue(u"Data/Hora", time.strftime("%c",time.localtime(msgInfo["imap.envelope"]["date"])))
self.addTextTitleValue(u"Remetente", msgInfo["imap.envelope"]["from"][0].formatAddress())
self.addTextTitleValue(u"Assunto" , msgInfo["imap.envelope"]["subject"])
self.addHtmlTemplate(u"%(htmlpreoff)s")
......
......@@ -28,7 +28,10 @@ def decode_header ( header ):
if charset:
final = final+unicode(part,charset)
else:
final = final+unicode(part,"ascii")
try:
final = final+unicode(part,"utf-8")
except:
final = final+unicode(part,"latin")
return final
## Read configuration
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment