summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-06-03 22:42:11 -0400
committerLance Stout <lancestout@gmail.com>2010-06-03 22:56:57 -0400
commit253de8518cfb2461f2172fbffd9b2a252924cb00 (patch)
treeeab864dd68064fa3f1ca6a9ce1fa0dce29d5af5d
parente700a54d11a01c0ed24cddb14ceac0511fbc8372 (diff)
downloadslixmpp-253de8518cfb2461f2172fbffd9b2a252924cb00.tar.gz
slixmpp-253de8518cfb2461f2172fbffd9b2a252924cb00.tar.bz2
slixmpp-253de8518cfb2461f2172fbffd9b2a252924cb00.tar.xz
slixmpp-253de8518cfb2461f2172fbffd9b2a252924cb00.zip
Modified xmlstream.py to pass a clean stanza object to each stream handler.
The previous version passed the same stanza object to each registered handler, which can cause issues when the stanza object is modified by one handler. The next handler receives the stanza with the modifications, not the original stanza.
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 6b92abca..003ead15 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -21,6 +21,7 @@ import threading
import time
import traceback
import types
+import copy
import xml.sax.saxutils
from . import scheduler
@@ -305,19 +306,18 @@ class XMLStream(object):
#convert XML into Stanza
logging.debug("RECV: %s" % cElementTree.tostring(xmlobj))
xmlobj = self.incoming_filter(xmlobj)
- stanza = None
+ stanza_type = StanzaBase
for stanza_class in self.__root_stanza:
if xmlobj.tag == "{%s}%s" % (self.default_ns, stanza_class.name):
- #if self.__root_stanza[stanza_class].match(xmlobj):
- stanza = stanza_class(self, xmlobj)
+ stanza_type = stanza_class
break
- if stanza is None:
- stanza = StanzaBase(self, xmlobj)
unhandled = True
+ stanza = stanza_type(self, xmlobj)
for handler in self.__handlers:
if handler.match(stanza):
- handler.prerun(stanza)
- self.eventqueue.put(('stanza', handler, stanza))
+ stanza_copy = stanza_type(self, copy.deepcopy(xmlobj))
+ handler.prerun(stanza_copy)
+ self.eventqueue.put(('stanza', handler, stanza_copy))
if handler.checkDelete(): self.__handlers.pop(self.__handlers.index(handler))
unhandled = False
if unhandled: