# HG changeset patch # User Goffi # Date 1548529665 -3600 # Node ID 33fa70c102de7bf03eb5d286e50e960893abb350 # Parent 181735d1b0622b4e4d1a0178c40e3214f5896dcc plugin XEP-0045: fixed crash when is used at an unexpected time. diff -r 181735d1b062 -r 33fa70c102de sat/core/xmpp.py --- a/sat/core/xmpp.py Fri Jan 25 09:06:29 2019 +0100 +++ b/sat/core/xmpp.py Sat Jan 26 20:07:45 2019 +0100 @@ -871,7 +871,10 @@ if message_elt.uri is None: # wokkel element parsing strip out root namespace - message_elt.uri = C.NS_CLIENT + message_elt.defaultUri = message_elt.uri = C.NS_CLIENT + for c in message_elt.children: + if c.uri is None: + c.uri == C.NS_CLIENT elif message_elt.uri != C.NS_CLIENT: log.warning(_( u"received with a wrong namespace: {xml}" diff -r 181735d1b062 -r 33fa70c102de sat/plugins/plugin_xep_0045.py --- a/sat/plugins/plugin_xep_0045.py Fri Jan 25 09:06:29 2019 +0100 +++ b/sat/plugins/plugin_xep_0045.py Sat Jan 26 20:07:45 2019 +0100 @@ -1133,6 +1133,24 @@ u"received history in unexpected state in room {room} (state: " u"{state})").format(room = room.roomJID.userhost(), state = room.state)) + if not hasattr(room, "_history_d"): + # XXX: this hack is due to buggy behaviour seen in the wild because of the + # "mod_delay" prosody module being activated. This module add an + # unexpected elements which break our workflow. + log.warning(_(u"storing the unexpected message anyway, to avoid loss")) + # we have to restore URI which are stripped by wokkel parsing + for c in message.element.children: + if c.uri is None: + c.uri = C.NS_CLIENT + mess_data = self.client.messageProt.parseMessage(message.element) + message.element._mess_data = mess_data + self._addToHistory(None, user, message) + if mess_data[u'message'] or mess_data[u'subject']: + self.host.bridge.messageNew( + *self.client.messageGetBridgeArgs(mess_data), + profile=self.client.profile + ) + return room._history_d.addCallback(self._addToHistory, user, message) room._history_d.addErrback(self._addToHistoryEb)