diff options
author | Lance Stout <lancestout@gmail.com> | 2011-06-20 16:25:56 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2011-06-20 16:25:56 -0700 |
commit | d8d9e8df16c07bd13bbac72e4445a2930407b244 (patch) | |
tree | b2a02ebf569eb24bf5d91618af8f2575dae4628b /sleekxmpp | |
parent | 58aa944a5e07032fc8d5770347f82e7c2ce6c948 (diff) | |
download | slixmpp-sleek-1.0.0-beta5.tar.gz slixmpp-sleek-1.0.0-beta5.tar.bz2 slixmpp-sleek-1.0.0-beta5.tar.xz slixmpp-sleek-1.0.0-beta5.zip |
Fix stanza clobbering when replying to errors.sleek-1.0.0-beta5sleek-1.0-Beta51.0.0-beta51.0-Beta5
If a stanza handler raised an exception, the exception was processed
and replied by the modified stanza, not a stanza with the original
content.
A copy is now made before handler processing, and if an exception occurs
it is the copy that processes the exception using the original content.
Diffstat (limited to 'sleekxmpp')
-rw-r--r-- | sleekxmpp/stanza/message.py | 2 | ||||
-rw-r--r-- | sleekxmpp/xmlstream/xmlstream.py | 13 |
2 files changed, 9 insertions, 6 deletions
diff --git a/sleekxmpp/stanza/message.py b/sleekxmpp/stanza/message.py index cb3d344c..3518fc7a 100644 --- a/sleekxmpp/stanza/message.py +++ b/sleekxmpp/stanza/message.py @@ -97,7 +97,7 @@ class Message(RootStanza): clear -- Indicates if existing content should be removed before replying. Defaults to True. """ - StanzaBase.reply(self) + StanzaBase.reply(self, clear) if self['type'] == 'groupchat': self['to'] = self['to'].bare diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py index 5bc71f04..6282c8d0 100644 --- a/sleekxmpp/xmlstream/xmlstream.py +++ b/sleekxmpp/xmlstream/xmlstream.py @@ -944,13 +944,14 @@ class XMLStream(object): func -- The event handler to execute. args -- Arguments to the event handler. """ + orig = copy.copy(args[0]) try: func(*args) except Exception as e: error_msg = 'Error processing event handler: %s' log.exception(error_msg % str(func)) - if hasattr(args[0], 'exception'): - args[0].exception(e) + if hasattr(orig, 'exception'): + orig.exception(e) def _event_runner(self): """ @@ -973,6 +974,7 @@ class XMLStream(object): etype, handler = event[0:2] args = event[2:] + orig = copy.copy(args[0]) if etype == 'stanza': try: @@ -980,7 +982,7 @@ class XMLStream(object): except Exception as e: error_msg = 'Error processing stream handler: %s' log.exception(error_msg % handler.name) - args[0].exception(e) + orig.exception(e) elif etype == 'schedule': try: log.debug('Scheduled event: %s' % args) @@ -989,6 +991,7 @@ class XMLStream(object): log.exception('Error processing scheduled task') elif etype == 'event': func, threaded, disposable = handler + orig = copy.copy(args[0]) try: if threaded: x = threading.Thread( @@ -1001,8 +1004,8 @@ class XMLStream(object): except Exception as e: error_msg = 'Error processing event handler: %s' log.exception(error_msg % str(func)) - if hasattr(args[0], 'exception'): - args[0].exception(e) + if hasattr(orig, 'exception'): + orig.exception(e) elif etype == 'quit': log.debug("Quitting event runner thread") return False |