diff options
author | lovetox <philipp@hoerist.com> | 2020-06-23 22:49:56 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2020-06-23 22:51:48 +0300 |
commit | e148d24f259de953c1c5328b0ae9da8eea9e77f8 (patch) | |
tree | 3f07c91cfcc03c992945fa2bac595a1fc0b8cb6a /nbxmpp | |
parent | dd74e6c576073db5c43bfacb47fd4814b2f55768 (diff) |
OMEMO: Correctly parse prekey value
The prekey value can be 'true' or '1'
Fixes #109
Diffstat (limited to 'nbxmpp')
-rw-r--r-- | nbxmpp/modules/omemo.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/nbxmpp/modules/omemo.py b/nbxmpp/modules/omemo.py index 91ec267..5e3dfcf 100644 --- a/nbxmpp/modules/omemo.py +++ b/nbxmpp/modules/omemo.py @@ -26,6 +26,7 @@ from nbxmpp.util import callback from nbxmpp.util import b64decode from nbxmpp.util import b64encode from nbxmpp.util import raise_error +from nbxmpp.util import from_xs_boolean from nbxmpp.structs import StanzaHandler from nbxmpp.structs import OMEMOMessage from nbxmpp.structs import OMEMOBundle @@ -111,7 +112,14 @@ class OMEMO(BaseModule): if rid is None: raise StanzaMalformed('rid not found') - prekey = kn.getAttr('prekey') == 'true' + prekey = kn.getAttr('prekey') + if prekey is None: + prekey = False + else: + try: + prekey = from_xs_boolean(prekey) + except ValueError as error: + raise StanzaMalformed(error) try: keys[int(rid)] = (b64decode(kn.getData(), bytes), prekey) |