From 909c86552432e05a0e9b20b8589060f93404d620 Mon Sep 17 00:00:00 2001 From: nicoco Date: Thu, 8 Feb 2024 20:51:19 +0100 Subject: [PATCH] XEP-0313: Do not try to parse date for fields without value. Without this we end up passing "None" instead of a str to the date parser, which raises a TypeError. It happens if you try to provide a form to be filled, when slixmpp acts as a MAM *server*. --- slixmpp/plugins/xep_0313/stanza.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slixmpp/plugins/xep_0313/stanza.py b/slixmpp/plugins/xep_0313/stanza.py index b1c5249f..cb943f98 100644 --- a/slixmpp/plugins/xep_0313/stanza.py +++ b/slixmpp/plugins/xep_0313/stanza.py @@ -82,7 +82,7 @@ class MAM(ElementBase): def get_start(self) -> Optional[datetime]: fields = self.get_fields() field = fields.get('start') - if field: + if field and field["value"]: return xep_0082.parse(field['value']) return None @@ -95,7 +95,7 @@ class MAM(ElementBase): def get_end(self) -> Optional[datetime]: fields = self.get_fields() field = fields.get('end') - if field: + if field and field["value"]: return xep_0082.parse(field['value']) return None