also replace non-character unicode AFTER decryption. Fixes #6974

This commit is contained in:
Yann Leboulanger 2011-09-16 23:42:28 +02:00
parent e5bb7672c2
commit b27c27685e
3 changed files with 9 additions and 1 deletions

View File

@ -977,6 +977,8 @@ class ConnectionHandlersBase:
if keyID:
def decrypt_thread(encmsg, keyID, obj):
decmsg = self.gpg.decrypt(encmsg, keyID)
decmsg = self.connection.Dispatcher.replace_non_character(
decmsg)
# \x00 chars are not allowed in C (so in GTK)
obj.msgtxt = helpers.decode_string(decmsg.replace('\x00',
''))

View File

@ -492,6 +492,9 @@ class EncryptedStanzaSession(ArchivingStanzaSession):
for child in parsed.getChildren():
stanza.addChild(node=child)
# replace non-character unicode
stranza = self.conn.connection.Dispatcher.replace_non_character(stanza)
return stanza
def decrypt(self, ciphertext):

View File

@ -197,6 +197,9 @@ class XMPPDispatcher(PlugIn):
raise ValueError('Incorrect stream start: (%s,%s). Terminating.'
% (tag, ns))
def replace_non_character(self, data):
return re.sub(self.invalid_chars_re, u'\ufffd'.encode('utf-8'), data)
def ProcessNonBlocking(self, data):
"""
Check incoming stream for data waiting
@ -212,7 +215,7 @@ class XMPPDispatcher(PlugIn):
# disconnect method will never be called.
# Is this intended?
# also look at transports start_disconnect()
data = re.sub(self.invalid_chars_re, u'\ufffd'.encode('utf-8'), data)
data = self.replace_non_character(data)
for handler in self._cycleHandlers:
handler(self)
if len(self._pendingExceptions) > 0: