From 3978078710774d9675513f0624cde9f1b1ff2615 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 4 Sep 2015 01:59:40 +0200 Subject: vcard-temp: add some checks against wrong input --- slixmpp/plugins/xep_0054/stanza.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/slixmpp/plugins/xep_0054/stanza.py b/slixmpp/plugins/xep_0054/stanza.py index cdd6215e..13b36320 100644 --- a/slixmpp/plugins/xep_0054/stanza.py +++ b/slixmpp/plugins/xep_0054/stanza.py @@ -324,7 +324,10 @@ class Birthday(ElementBase): def get_bday(self): if not self.xml.text: return None - return xep_0082.parse(self.xml.text) + try: + return xep_0082.parse(self.xml.text) + except ValueError: + return self.xml.text class Rev(ElementBase): @@ -343,7 +346,10 @@ class Rev(ElementBase): def get_rev(self): if not self.xml.text: return None - return xep_0082.parse(self.xml.text) + try: + return xep_0082.parse(self.xml.text) + except ValueError: + return self.xml.text class Title(ElementBase): @@ -523,8 +529,11 @@ class TimeZone(ElementBase): def get_tz(self): if not self.xml.text: return xep_0082.tzutc() - time = xep_0082.parse('00:00:00%s' % self.xml.text) - return time.tzinfo + try: + time = xep_0082.parse('00:00:00%s' % self.xml.text) + return time.tzinfo + except ValueError: + return self.xml.text register_stanza_plugin(VCardTemp, Name) -- cgit v1.2.3