Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2020-04-18 17:26:20 +0300
committerlovetox <philipp@hoerist.com>2020-04-18 17:26:20 +0300
commit442eae7e26344df4a4b88611670731b79f616c68 (patch)
tree7be7d71d25056383f1bfee7b82f07a22e39aad40
parentb15c9009305e08ad738461989976297273dcc7dc (diff)
EntityCaps: Parse more strictly
-rw-r--r--nbxmpp/modules/entity_caps.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/nbxmpp/modules/entity_caps.py b/nbxmpp/modules/entity_caps.py
index 7636e40..4599522 100644
--- a/nbxmpp/modules/entity_caps.py
+++ b/nbxmpp/modules/entity_caps.py
@@ -69,18 +69,31 @@ class EntityCaps(BaseModule):
client.send_stanza(iq)
raise NodeProcessed
- @staticmethod
- def _process_entity_caps(_client, stanza, properties):
+ def _process_entity_caps(self, _client, stanza, properties):
caps = stanza.getTag('c', namespace=NS_CAPS)
if caps is None:
- properties.entity_caps = EntityCapsData()
+ return
+
+ hash_algo = caps.getAttr('hash')
+ if hash_algo != 'sha-1':
+ self._log.warning('Unsupported hashing algorithm used: %s',
+ hash_algo)
+ return
+
+ node = caps.getAttr('node')
+ if not node:
+ self._log.warning('node attribute missing')
+ return
+
+ ver = caps.getAttr('ver')
+ if not ver:
+ self._log.warning('ver attribute missing')
return
properties.entity_caps = EntityCapsData(
- hash=caps.getAttr('hash'),
- node=caps.getAttr('node'),
- ver=caps.getAttr('ver')
- )
+ hash=hash_algo,
+ node=node,
+ ver=ver)
@property
def caps(self):