plugin XEP-0045: fixed crash when <delay> is used at an unexpected time.

This commit is contained in:
Goffi 2019-01-26 20:07:45 +01:00
commit 198db6c2ca
2 changed files with 22 additions and 1 deletions

View file

@ -871,7 +871,10 @@ class SatMessageProtocol(xmppim.MessageProtocol):
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 <message> with a wrong namespace: {xml}"

View file

@ -1133,6 +1133,24 @@ class SatMUCClient(muc.MUCClient):
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 <delay> 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)