From bee3b7c75c27a7f162f2e745f6d5835ca16b11d6 Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Mon, 26 Jul 2010 00:51:07 +0000 Subject: Support old and deprecated XEP 0091 because it's still used on buggy servers like @conference.codingteam.net. Fixed #1677 --- src/common.py | 5 ++++- src/gui.py | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/common.py b/src/common.py index b71f84fc..6cd83248 100644 --- a/src/common.py +++ b/src/common.py @@ -264,7 +264,10 @@ def datetime_tuple(timestamp): """ timestamp = timestamp.split('.')[0] timestamp = timestamp.replace('-', '') - ret = datetime.strptime(timestamp, '%Y%m%dT%H:%M:%SZ') + try: + ret = datetime.strptime(timestamp, '%Y%m%dT%H:%M:%SZ') + except ValueError: # Support the deprecated format, XEP 0091 :( + ret = datetime.strptime(timestamp, '%Y%m%dT%H:%M:%S') # convert UTC to local time, with DST etc. dst = timedelta(seconds=time.altzone) ret -= dst diff --git a/src/gui.py b/src/gui.py index 7a26f59a..6dae9635 100644 --- a/src/gui.py +++ b/src/gui.py @@ -387,7 +387,14 @@ class Gui(object): delayed = True date = common.datetime_tuple(delay_tag.getAttr('stamp')) else: - delayed = False + # We support the OLD and deprecated XEP: http://xmpp.org/extensions/xep-0091.html + # But it sucks, please, Jabber servers, don't do this :( + delay_tag = stanza.getTag('x', namespace='jabber:x:delay') + if delay_tag: + delayed = True + date = common.datetime_tuple(delay_tag.getAttr('stamp')) + else: + delayed = False if stanza.getType() != 'groupchat': return # ignore all messages not comming from a MUC nick_from = stanza.getFrom().getResource() -- cgit v1.2.3