From 83260b827af7db2f7d827d39373a1f041ed1c6aa Mon Sep 17 00:00:00 2001 From: Goffi Date: Tue, 14 Apr 2020 20:25:05 +0200 Subject: [PATCH] core (memory/disco): fixed types of disco extensions: typeCheck() is not automatically called on reception by Wokkel, as a result extensions fields values may be strings instead of the field type. TypeCheck is now explicitly called in memory.disco to avoid that. It is not called immediately on reception as the string value is needed to calculate the capability hash --- sat/memory/disco.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sat/memory/disco.py b/sat/memory/disco.py index 25ec4055..0fec5ce2 100755 --- a/sat/memory/disco.py +++ b/sat/memory/disco.py @@ -87,6 +87,9 @@ class HashManager(object): for hash_, xml in hashes.items(): element = xml_tools.ElementParser()(xml) disco_info = disco.DiscoInfo.fromElement(element) + for ext_form in disco_info.extensions.values(): + # wokkel doesn't call typeCheck on reception, so we do it here + ext_form.typeCheck() if not disco_info.features and not disco_info.identities: log.warning( _( @@ -180,6 +183,12 @@ class Discovery(object): # capability hash is not available, we'll compute one def infosCb(disco_infos): cap_hash = self.generateHash(disco_infos) + for ext_form in disco_infos.extensions.values(): + # wokkel doesn't call typeCheck on reception, so we do it here + # to avoid ending up with incorrect types. We have to do it after + # the hash has been generated (str value is needed to compute the + # hash) + ext_form.typeCheck() self.hashes[cap_hash] = disco_infos self.host.memory.updateEntityData( jid_, C.ENTITY_CAP_HASH, cap_hash, profile_key=client.profile @@ -405,7 +414,7 @@ class Discovery(object): def _discoInfos( self, entity_jid_s, node="", use_cache=True, profile_key=C.PROF_KEY_NONE ): - """ Discovery method for the bridge + """Discovery method for the bridge @param entity_jid_s: entity we want to discover @param use_cache(bool): if True, use cached data if available @param node(unicode): optional node to use