Ticket #3083: xmpppy.diff

File xmpppy.diff, 1.3 KB (added by asterix, 2 years ago)
  • src/common/xmpp/dispatcher_nb.py

     
    4949                self.RegisterHandlerOnce, self.UnregisterHandler, self.RegisterProtocol, \ 
    5050                self.SendAndWaitForResponse, self.send,self.disconnect, \ 
    5151                self.SendAndCallForResponse, self.getAnID, self.Event] 
     52                self.previous_size = 0 
    5253 
    5354        def getAnID(self): 
    5455                global ID 
     
    131132                if len(self._pendingExceptions) > 0: 
    132133                        _pendingException = self._pendingExceptions.pop() 
    133134                        raise _pendingException[0], _pendingException[1], _pendingException[2] 
     135                # test incomming stanza before we parse it to avoid disconnections 
     136                size = len(data) 
     137                # 16384 is the maximum size of a SSL packet 
     138                # This mean this stanza or previous stanza is incomplete. Don't check it 
     139                if size != 16384 and self.previous_size != 16384: 
     140                        if data.find('stream:') < 0: 
     141                                try: 
     142                                        simplexml.NodeBuilder(data) 
     143                                except ExpatError: 
     144                                        self.DEBUG(10*'=' + '<<MALFORMED XML>>' + 10*'=') 
     145                                        self.DEBUG(data) 
     146                                        self.DEBUG(10*'=' + '<< END MALFORMED XML>>' + 10*'=') 
     147                                        self.previous_size = size 
     148                                        return '0' 
     149                self.previous_size = size 
    134150                try: 
    135151                        self.Stream.Parse(data) 
    136152                        # end stream:stream tag received