Skip to content
Snippets Groups Projects
Commit 172a4c01 authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

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

parent 33ba925c
No related branches found
No related tags found
No related merge requests found
......@@ -978,6 +978,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',
''))
......
......@@ -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):
......
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment