[FIX] Fixed IQ sending with empty <from> that crashes new versions of ejabberd
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
from sleekxmpp.plugins.xep_0054 import XEP_0054
|
from sleekxmpp.plugins.xep_0054 import XEP_0054
|
||||||
|
from sleekxmpp.plugins.xep_0030 import XEP_0030
|
||||||
from sleekxmpp import Iq
|
from sleekxmpp import Iq
|
||||||
|
from sleekxmpp.xmlstream import JID
|
||||||
from sleekxmpp.exceptions import XMPPError
|
from sleekxmpp.exceptions import XMPPError
|
||||||
|
|
||||||
from telethon.update_state import UpdateState
|
from telethon.update_state import UpdateState
|
||||||
@@ -37,7 +39,51 @@ def patched_stop_workers(self):
|
|||||||
self._worker_threads.clear()
|
self._worker_threads.clear()
|
||||||
self._workers = n
|
self._workers = n
|
||||||
|
|
||||||
|
def patched_get_info(self, jid=None, node=None, local=None, cached=None, **kwargs):
|
||||||
|
|
||||||
|
if local is None:
|
||||||
|
if jid is not None and not isinstance(jid, JID):
|
||||||
|
jid = JID(jid)
|
||||||
|
if self.xmpp.is_component:
|
||||||
|
if jid.domain == self.xmpp.boundjid.domain:
|
||||||
|
local = True
|
||||||
|
else:
|
||||||
|
if str(jid) == str(self.xmpp.boundjid):
|
||||||
|
local = True
|
||||||
|
jid = jid.full
|
||||||
|
elif jid in (None, ''):
|
||||||
|
local = True
|
||||||
|
|
||||||
|
if local:
|
||||||
|
log.debug("Looking up local disco#info data " + \
|
||||||
|
"for %s, node %s.", jid, node)
|
||||||
|
info = self.api['get_info'](jid, node,
|
||||||
|
kwargs.get('ifrom', None),
|
||||||
|
kwargs)
|
||||||
|
info = self._fix_default_info(info)
|
||||||
|
return self._wrap(kwargs.get('ifrom', None), jid, info)
|
||||||
|
|
||||||
|
if cached:
|
||||||
|
info = self.api['get_cached_info'](jid, node,
|
||||||
|
kwargs.get('ifrom', None),
|
||||||
|
kwargs)
|
||||||
|
if info is not None:
|
||||||
|
return self._wrap(kwargs.get('ifrom', None), jid, info)
|
||||||
|
|
||||||
|
iq = self.xmpp.Iq()
|
||||||
|
# Check dfrom parameter for backwards compatibility
|
||||||
|
iq['from'] = kwargs.get('ifrom', kwargs.get('dfrom', ''))
|
||||||
|
iq['from'] = self.xmpp.boundjid.bare if (not iq['from'] or iq['from'] == '') else iq['from']
|
||||||
|
iq['to'] = jid
|
||||||
|
iq['type'] = 'get'
|
||||||
|
iq['disco_info']['node'] = node if node else ''
|
||||||
|
return iq.send(timeout=kwargs.get('timeout', None),
|
||||||
|
block=kwargs.get('block', True),
|
||||||
|
callback=kwargs.get('callback', None),
|
||||||
|
timeout_callback=kwargs.get('timeout_callback', None))
|
||||||
|
|
||||||
|
|
||||||
# hey i'm baboon
|
# hey i'm baboon
|
||||||
XEP_0054._handle_get_vcard = patched_handle_get_vcard
|
XEP_0054._handle_get_vcard = patched_handle_get_vcard
|
||||||
|
XEP_0030.get_info = patched_get_info
|
||||||
UpdateState.stop_workers = patched_stop_workers
|
UpdateState.stop_workers = patched_stop_workers
|
||||||
|
|||||||
Reference in New Issue
Block a user