classification
Title: Parsing failures in parsedate_tz
Type: feature request Stage: test needed
Components: Library (Lib) Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: therve, tzot (2)
Priority: normal Keywords

Created on 2005-03-13 16:11 by therve, last changed 2009-02-16 01:01 by ajaksu2.

Messages (3)
msg60699 - (view) Author: Thomas Herve (therve) Date: 2005-03-13 16:11
Some email clients send bad-formed datetimes, not
parsed by parsedate_tz (both rfc822.py and
email._parseaddr.py). 

The format not recognized is "HH.MM.SS".

I don't know if it's worth taking in account but in
doubt I give a small patch for email._parseaddr :

----------------------------------------------------------------
@@ -90,6 +100,14 @@ def parsedate_tz(data):
         tss = '0'
     elif len(tm) == 3:
         [thh, tmm, tss] = tm
+    elif len(tm) == 1:
+        # Small hack to get HH.MM.ss
+        tm = tm[0].split(".")
+        if len(tm) == 2:
+            [thh, tmm] = tm
+            tss = '0'
+        elif len(tm) == 3:
+            [thh, tmm, tss] = tm
     else:
         return None
----------------------------------------------------------------
msg60700 - (view) Author: Χρήστος Γεωργίου (Christos Georgiou) (tzot) Date: 2005-03-20 10:36
Logged In: YES 
user_id=539787

It would be helpful if you could provide some of these
malformed Date headers, so that test cases can be generated.
msg60701 - (view) Author: Thomas Herve (therve) Date: 2005-03-20 12:29
Logged In: YES 
user_id=1038797

Of course, here's and example of malformed Date header :
"Wed, 02 Mar 2005 09.26.53 +0800".
History
Date User Action Args
2009-02-16 01:01:21ajaksu2setstage: test needed
type: feature request
versions: + Python 2.7, - Python 2.3
2005-03-13 16:11:46thervecreate