comparison sat/core/xmpp.py @ 2714:57eac4fd0ec0

core (xmpp): check <message> namespace in parseMessage, and accept empty namespace (happen with Wokkel)
author Goffi <goffi@goffi.org>
date Fri, 07 Dec 2018 17:46:50 +0100
parents 2ea2369ae7de
children b35c84ea73cf
comparison
equal deleted inserted replaced
2713:19000c506d0c 2714:57eac4fd0ec0
837 if self.sendHistory: 837 if self.sendHistory:
838 post_xml_treatments.addCallback(self.messageAddToHistory) 838 post_xml_treatments.addCallback(self.messageAddToHistory)
839 839
840 840
841 class SatMessageProtocol(xmppim.MessageProtocol): 841 class SatMessageProtocol(xmppim.MessageProtocol):
842
842 def __init__(self, host): 843 def __init__(self, host):
843 xmppim.MessageProtocol.__init__(self) 844 xmppim.MessageProtocol.__init__(self)
844 self.host = host 845 self.host = host
845 846
846 def parseMessage(self, message_elt): 847 def parseMessage(self, message_elt):
854 if message_elt.name != u"message": 855 if message_elt.name != u"message":
855 log.warning(_( 856 log.warning(_(
856 u"parseMessage used with a non <message/> stanza, ignoring: {xml}" 857 u"parseMessage used with a non <message/> stanza, ignoring: {xml}"
857 .format(xml=message_elt.toXml()))) 858 .format(xml=message_elt.toXml())))
858 return {} 859 return {}
860
861 if message_elt.uri is None:
862 # wokkel element parsing strip out root namespace
863 message_elt.uri = C.NS_CLIENT
864 elif message_elt.uri != C.NS_CLIENT:
865 log.warning(_(
866 u"received <message> with a wrong namespace: {xml}"
867 .format(xml=message_elt.toXml())))
868
859 client = self.parent 869 client = self.parent
860 message = {} 870 message = {}
861 subject = {} 871 subject = {}
862 extra = {} 872 extra = {}
863 data = { 873 data = {