Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjell Braden <afflux.gajim@pentabarf.de>2013-08-25 19:00:04 +0400
committerKjell Braden <afflux.gajim@pentabarf.de>2013-08-25 19:00:04 +0400
commit661ff5fd4c0e0e49fd31e2114d2076e21d8e3b1e (patch)
treefe33aca80b63bb9f56c856f3318243b52232c17a
parent118a7d7a416ea30e1a2f57987f58425c134419fb (diff)
gotr: make sure no messages are sent in plain when OTR fails, also log failures
-rw-r--r--gotr/manifest.ini2
-rw-r--r--gotr/otrmodule.py72
2 files changed, 39 insertions, 35 deletions
diff --git a/gotr/manifest.ini b/gotr/manifest.ini
index c778037..10f3432 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.5
+version: 1.7.6
description: Provide OTR encryption
authors: Kjell Braden <afflux.gajim@pentabarf.de>
homepage: http://gajim-otr.pentabarf.de
diff --git a/gotr/otrmodule.py b/gotr/otrmodule.py
index 2d99ad7..b72ae01 100644
--- a/gotr/otrmodule.py
+++ b/gotr/otrmodule.py
@@ -592,50 +592,54 @@ class OtrPlugin(GajimPlugin):
return PASS
def handle_outgoing_msg(self, event):
- if hasattr(event, 'otrmessage'):
- return PASS
+ try:
+ if hasattr(event, 'otrmessage'):
+ return PASS
- xep_200 = bool(event.session) and event.session.enable_encryption
+ xep_200 = bool(event.session) and event.session.enable_encryption
- potrrootlog.debug('got event {0} xep_200={1}'.format(pformat(event.__dict__), xep_200))
- if xep_200 or not event.message:
- return PASS
+ potrrootlog.debug('got event {0} xep_200={1}'.format(pformat(event.__dict__), xep_200))
+ if xep_200 or not event.message:
+ return PASS
- if event.session:
- fjid = event.session.get_to()
- else:
- fjid = event.jid
- if event.resource:
- fjid += '/' + event.resource
+ if event.session:
+ fjid = event.session.get_to()
+ else:
+ fjid = event.jid
+ if event.resource:
+ fjid += '/' + event.resource
- message = event.xhtml or escape(event.message)
- message = message.encode('utf8')
+ message = event.xhtml or escape(event.message)
+ message = message.encode('utf8')
- potrrootlog.debug('processing message={0!r} from fjid={1!r}'.format(message, fjid))
+ potrrootlog.debug('processing message={0!r} from fjid={1!r}'.format(message, fjid))
- try:
- newmsg = self.us[event.account].getContext(fjid).sendMessage(
- potr.context.FRAGMENT_SEND_ALL_BUT_LAST, message,
- appdata={'session':event.session})
- potrrootlog.debug('processed message={0!r}'.format(newmsg))
- except potr.context.NotEncryptedError, e:
- if e.args[0] == potr.context.EXC_FINISHED:
- self.gajim_log(_('Your message was not send. Either end '
- 'your private conversation, or restart it'), event.account,
- fjid)
- return IGNORE
- else:
- raise e
+ try:
+ newmsg = self.us[event.account].getContext(fjid).sendMessage(
+ potr.context.FRAGMENT_SEND_ALL_BUT_LAST, message,
+ appdata={'session':event.session})
+ potrrootlog.debug('processed message={0!r}'.format(newmsg))
+ except potr.context.NotEncryptedError, e:
+ if e.args[0] == potr.context.EXC_FINISHED:
+ self.gajim_log(_('Your message was not send. Either end '
+ 'your private conversation, or restart it'), event.account,
+ fjid)
+ return IGNORE
+ else:
+ raise e
- if event.xhtml: # if we had html before, replace with new content
- event.xhtml = newmsg
+ if event.xhtml: # if we had html before, replace with new content
+ event.xhtml = newmsg
- stripper = HTMLStripper()
- stripper.feed((newmsg or '').decode('utf8'))
- event.message = stripper.stripped_data
+ stripper = HTMLStripper()
+ stripper.feed((newmsg or '').decode('utf8'))
+ event.message = stripper.stripped_data
- return PASS
+ return PASS
+ except:
+ potrrootlog.exception('exception in outgoing message handler, message (hopefully) discarded')
+ return IGNORE
class HTMLStripper(HTMLParser):
def reset(self):