- subject on replies was not parsed correctly (or should I say was
parsed more than necessary)
- unicode can handle invalid characters without needing a special
function

Fixes #164
This commit is contained in:
mailchuck 2016-01-04 15:43:24 +01:00
parent 376b755acc
commit 106ac6ce78
Signed by untrusted user who does not match committer: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -983,14 +983,13 @@ class MyForm(settingsmixin.SMainWindow):
tableWidget.setItem(0, i, items[i]) tableWidget.setItem(0, i, items[i])
def addMessageListItemSent(self, tableWidget, toAddress, fromAddress, subject, status, ackdata, lastactiontime): def addMessageListItemSent(self, tableWidget, toAddress, fromAddress, subject, status, ackdata, lastactiontime):
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
acct = accountClass(fromAddress) acct = accountClass(fromAddress)
acct.parseMessage(toAddress, fromAddress, subject, "") acct.parseMessage(toAddress, fromAddress, subject, "")
items = [] items = []
MessageList_AddressWidget(items, str(toAddress), unicode(acct.toLabel, 'utf-8')) MessageList_AddressWidget(items, str(toAddress), unicode(acct.toLabel, 'utf-8'))
MessageList_AddressWidget(items, str(fromAddress), unicode(acct.fromLabel, 'utf-8')) MessageList_AddressWidget(items, str(fromAddress), unicode(acct.fromLabel, 'utf-8'))
MessageList_SubjectWidget(items, str(subject), unicode(acct.subject, 'utf-8')) MessageList_SubjectWidget(items, str(subject), unicode(acct.subject, 'utf-8', 'replace'))
if status == 'awaitingpubkey': if status == 'awaitingpubkey':
statusText = _translate( statusText = _translate(
@ -1052,7 +1051,6 @@ class MyForm(settingsmixin.SMainWindow):
acct = accountClass(fromAddress) acct = accountClass(fromAddress)
if acct is None: if acct is None:
acct = BMAccount(fromAddress) acct = BMAccount(fromAddress)
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
acct.parseMessage(toAddress, fromAddress, subject, "") acct.parseMessage(toAddress, fromAddress, subject, "")
items = [] items = []
@ -1061,7 +1059,7 @@ class MyForm(settingsmixin.SMainWindow):
# from # from
MessageList_AddressWidget(items, fromAddress, unicode(acct.fromLabel, 'utf-8'), not read) MessageList_AddressWidget(items, fromAddress, unicode(acct.fromLabel, 'utf-8'), not read)
# subject # subject
MessageList_SubjectWidget(items, str(subject), unicode(acct.subject, 'utf-8'), not read) MessageList_SubjectWidget(items, str(subject), unicode(acct.subject, 'utf-8', 'replace'), not read)
# time received # time received
time_item = myTableWidgetItem(l10n.formatTimestamp(received)) time_item = myTableWidgetItem(l10n.formatTimestamp(received))
time_item.setToolTip(l10n.formatTimestamp(received)) time_item.setToolTip(l10n.formatTimestamp(received))
@ -2405,8 +2403,6 @@ class MyForm(settingsmixin.SMainWindow):
# pseudo-mailing-list. The message will be broadcast out. This function # pseudo-mailing-list. The message will be broadcast out. This function
# puts the message on the 'Sent' tab. # puts the message on the 'Sent' tab.
def displayNewSentMessage(self, toAddress, toLabel, fromAddress, subject, message, ackdata): def displayNewSentMessage(self, toAddress, toLabel, fromAddress, subject, message, ackdata):
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
message = shared.fixPotentiallyInvalidUTF8Data(message)
acct = accountClass(fromAddress) acct = accountClass(fromAddress)
acct.parseMessage(toAddress, fromAddress, subject, message) acct.parseMessage(toAddress, fromAddress, subject, message)
for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]: for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
@ -2419,7 +2415,7 @@ class MyForm(settingsmixin.SMainWindow):
continue continue
self.addMessageListItemSent(sent, toAddress, fromAddress, subject, "msgqueued", ackdata, time.time()) self.addMessageListItemSent(sent, toAddress, fromAddress, subject, "msgqueued", ackdata, time.time())
self.getAccountTextedit(acct).setPlainText(unicode(message, 'utf-8)')) self.getAccountTextedit(acct).setPlainText(unicode(message, 'utf-8)', 'replace'))
def displayNewInboxMessage(self, inventoryHash, toAddress, fromAddress, subject, message): def displayNewInboxMessage(self, inventoryHash, toAddress, fromAddress, subject, message):
if toAddress == str_broadcast_subscribers: if toAddress == str_broadcast_subscribers:
@ -2435,7 +2431,6 @@ class MyForm(settingsmixin.SMainWindow):
elif treeWidget == self.ui.treeWidgetYourIdentities and self.getCurrentAccount(treeWidget) is None: elif treeWidget == self.ui.treeWidgetYourIdentities and self.getCurrentAccount(treeWidget) is None:
ret = self.addMessageListItemInbox(tableWidget, "inbox", inventoryHash, toAddress, fromAddress, subject, time.time(), 0) ret = self.addMessageListItemInbox(tableWidget, "inbox", inventoryHash, toAddress, fromAddress, subject, time.time(), 0)
if ret is None: if ret is None:
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
acct.parseMessage(toAddress, fromAddress, subject, "") acct.parseMessage(toAddress, fromAddress, subject, "")
else: else:
acct = ret acct = ret
@ -3043,10 +3038,10 @@ class MyForm(settingsmixin.SMainWindow):
currentInboxRow = tableWidget.currentRow() currentInboxRow = tableWidget.currentRow()
toAddressAtCurrentInboxRow = tableWidget.item( toAddressAtCurrentInboxRow = tableWidget.item(
currentInboxRow, 0).data(Qt.UserRole) currentInboxRow, 0).address
acct = accountClass(toAddressAtCurrentInboxRow) acct = accountClass(toAddressAtCurrentInboxRow)
fromAddressAtCurrentInboxRow = tableWidget.item( fromAddressAtCurrentInboxRow = tableWidget.item(
currentInboxRow, 1).data(Qt.UserRole) currentInboxRow, 1).address
msgid = str(tableWidget.item( msgid = str(tableWidget.item(
currentInboxRow, 3).data(Qt.UserRole).toPyObject()) currentInboxRow, 3).data(Qt.UserRole).toPyObject())
queryreturn = sqlQuery( queryreturn = sqlQuery(
@ -3094,12 +3089,12 @@ class MyForm(settingsmixin.SMainWindow):
else: else:
widget['from'].setCurrentIndex(0) widget['from'].setCurrentIndex(0)
quotedText = self.quoted_text(unicode(messageAtCurrentInboxRow, 'utf-8')) quotedText = self.quoted_text(unicode(messageAtCurrentInboxRow, 'utf-8', 'replace'))
widget['message'].setText(quotedText) widget['message'].setText(quotedText)
if acct.subject[0:3] in ['Re:', 'RE:']: if acct.subject[0:3] in ['Re:', 'RE:']:
widget['subject'].setText(acct.subject) widget['subject'].setText(tableWidget.item(currentInboxRow, 2).label)
else: else:
widget['subject'].setText('Re: ' + acct.subject) widget['subject'].setText('Re: ' + tableWidget.item(currentInboxRow, 2).label)
self.ui.tabWidget.setCurrentIndex(1) self.ui.tabWidget.setCurrentIndex(1)
def on_action_InboxAddSenderToAddressBook(self): def on_action_InboxAddSenderToAddressBook(self):