diff options
author | mathieui <mathieui@mathieui.net> | 2021-04-09 20:40:30 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2021-04-09 20:40:30 +0200 |
commit | fcf666e3cb2f2656020a73e94df332f996924511 (patch) | |
tree | 35d71a04ec7d68e11e5ce0f5df29272dfb018687 | |
parent | 7ddcc3428fbc48814da301ce7cba9b1f855a0fa9 (diff) | |
download | slixmpp-fcf666e3cb2f2656020a73e94df332f996924511.tar.gz slixmpp-fcf666e3cb2f2656020a73e94df332f996924511.tar.bz2 slixmpp-fcf666e3cb2f2656020a73e94df332f996924511.tar.xz slixmpp-fcf666e3cb2f2656020a73e94df332f996924511.zip |
Fix #3441: Do not assign ID to inbound stanzas
-rw-r--r-- | slixmpp/stanza/iq.py | 4 | ||||
-rw-r--r-- | slixmpp/stanza/message.py | 4 | ||||
-rw-r--r-- | slixmpp/stanza/presence.py | 4 | ||||
-rw-r--r-- | slixmpp/xmlstream/stanzabase.py | 2 | ||||
-rw-r--r-- | slixmpp/xmlstream/xmlstream.py | 2 |
5 files changed, 8 insertions, 8 deletions
diff --git a/slixmpp/stanza/iq.py b/slixmpp/stanza/iq.py index 0242308e..044c9df8 100644 --- a/slixmpp/stanza/iq.py +++ b/slixmpp/stanza/iq.py @@ -58,14 +58,14 @@ class Iq(RootStanza): types = {'get', 'result', 'set', 'error'} plugin_attrib = name - def __init__(self, *args, **kwargs): + def __init__(self, *args, recv=False, **kwargs): """ Initialize a new <iq> stanza with an 'id' value. Overrides StanzaBase.__init__. """ StanzaBase.__init__(self, *args, **kwargs) - if self['id'] == '': + if not recv and self['id'] == '': if self.stream is not None: self['id'] = self.stream.new_id() else: diff --git a/slixmpp/stanza/message.py b/slixmpp/stanza/message.py index 7b033e37..debfb380 100644 --- a/slixmpp/stanza/message.py +++ b/slixmpp/stanza/message.py @@ -53,14 +53,14 @@ class Message(RootStanza): lang_interfaces = sub_interfaces types = {'normal', 'chat', 'headline', 'error', 'groupchat'} - def __init__(self, *args, **kwargs): + def __init__(self, *args, recv=False, **kwargs): """ Initialize a new <message /> stanza with an optional 'id' value. Overrides StanzaBase.__init__. """ StanzaBase.__init__(self, *args, **kwargs) - if self['id'] == '': + if not recv and self['id'] == '': if self.stream is not None and self.stream.use_message_ids: self['id'] = self.stream.new_id() else: diff --git a/slixmpp/stanza/presence.py b/slixmpp/stanza/presence.py index 297fcfea..022e7133 100644 --- a/slixmpp/stanza/presence.py +++ b/slixmpp/stanza/presence.py @@ -61,14 +61,14 @@ class Presence(RootStanza): 'subscribed', 'unsubscribe', 'unsubscribed'} showtypes = {'dnd', 'chat', 'xa', 'away'} - def __init__(self, *args, **kwargs): + def __init__(self, *args, recv=False, **kwargs): """ Initialize a new <presence /> stanza with an optional 'id' value. Overrides StanzaBase.__init__. """ StanzaBase.__init__(self, *args, **kwargs) - if self['id'] == '': + if not recv and self['id'] == '': if self.stream is not None and self.stream.use_presence_ids: self['id'] = self.stream.new_id() diff --git a/slixmpp/xmlstream/stanzabase.py b/slixmpp/xmlstream/stanzabase.py index 0fa5ef27..207ae588 100644 --- a/slixmpp/xmlstream/stanzabase.py +++ b/slixmpp/xmlstream/stanzabase.py @@ -1381,7 +1381,7 @@ class StanzaBase(ElementBase): namespace = 'jabber:client' def __init__(self, stream=None, xml=None, stype=None, - sto=None, sfrom=None, sid=None, parent=None): + sto=None, sfrom=None, sid=None, parent=None, recv=False): self.stream = stream if stream is not None: self.namespace = stream.default_ns diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index 02f4598c..d9edc5b2 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -1157,7 +1157,7 @@ class XMLStream(asyncio.BaseProtocol): xml.tag == stanza_class.tag_name(): stanza_type = stanza_class break - stanza = stanza_type(self, xml) + stanza = stanza_type(self, xml, recv=True) if stanza['lang'] is None and self.peer_default_lang: stanza['lang'] = self.peer_default_lang return stanza |