From 9599b15eb5e0b38551e3559ba992185fd7334a32 Mon Sep 17 00:00:00 2001 From: Kjell Braden Date: Fri, 28 Jun 2013 09:45:26 +0200 Subject: gotr: fix messages not being encrypted due to message encoding in events --- gotr/manifest.ini | 2 +- gotr/otrmodule.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'gotr') diff --git a/gotr/manifest.ini b/gotr/manifest.ini index a1653ef..80397e4 100644 --- a/gotr/manifest.ini +++ b/gotr/manifest.ini @@ -1,7 +1,7 @@ [info] name: Off-The-Record Encryption short_name: gotr -version: 1.7.3 +version: 1.7.4 description: Provide OTR encryption authors: Kjell Braden homepage: http://gajim-otr.pentabarf.de diff --git a/gotr/otrmodule.py b/gotr/otrmodule.py index 6c43980..adc9489 100644 --- a/gotr/otrmodule.py +++ b/gotr/otrmodule.py @@ -537,7 +537,7 @@ class OtrPlugin(GajimPlugin): try: ctx = self.us[account].getContext(event.fjid) - msgtxt, tlvs = ctx.receiveMessage(event.msgtxt, + msgtxt, tlvs = ctx.receiveMessage(event.msgtxt.encode('utf8'), appdata={'session':event.session}) except potr.context.NotOTRMessage, e: # received message was not OTR - pass it on @@ -583,10 +583,10 @@ class OtrPlugin(GajimPlugin): ctx.smpWindow.handle_tlv(tlvs) stripper = HTMLStripper() - stripper.feed(unicode(msgtxt or '')) + stripper.feed((msgtxt or '').decode('utf8')) event.msgtxt = stripper.stripped_data event.stanza.setBody(event.msgtxt) - event.stanza.setXHTML(msgtxt) + event.stanza.setXHTML((msgtxt or '').decode('utf8')) return PASS @@ -606,6 +606,7 @@ class OtrPlugin(GajimPlugin): fjid += '/' + event.resource message = event.xhtml or escape(event.message) + message = message.encode('utf8') try: newmsg = self.us[event.account].getContext(fjid).sendMessage( @@ -624,7 +625,7 @@ class OtrPlugin(GajimPlugin): event.xhtml = newmsg stripper = HTMLStripper() - stripper.feed(unicode(newmsg or '')) + stripper.feed((newmsg or '').decode('utf8')) event.message = stripper.stripped_data return PASS -- cgit v1.2.3