This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Parsing failures in parsedate_tz
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: python-dev, r.david.murray, therve, tzot
Priority: normal Keywords: patch

Created on 2005-03-13 16:11 by therve, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
parsedate.patch r.david.murray, 2010-08-24 01:51 review
Messages (6)
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".
msg114764 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-08-24 01:51
Here's a patch (essentially the one provided by Thomas) with unit test.
msg124718 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-27 17:38
Somehow I missed this in my pre-beta feature request review :(
msg130781 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-03-14 00:07
New changeset 9d7a83654870 by R David Murray in branch 'default':
#1162477: accept '.' in addition to ':' when parsing time in date header.
http://hg.python.org/cpython/rev/9d7a83654870
History
Date User Action Args
2022-04-11 14:56:10adminsetgithub: 41691
2011-03-14 00:08:05r.david.murraysetstatus: open -> closed
nosy: tzot, therve, r.david.murray, python-dev
resolution: accepted
stage: patch review -> resolved
2011-03-14 00:07:23python-devsetnosy: + python-dev
messages: + msg130781
2010-12-27 17:38:42r.david.murraysetnosy: tzot, therve, r.david.murray
messages: + msg124718
versions: + Python 3.3, - Python 3.2
2010-08-24 01:51:34r.david.murraysetfiles: + parsedate.patch
keywords: + patch
messages: + msg114764

stage: test needed -> patch review
2010-08-22 15:35:55r.david.murraysetassignee: r.david.murray
2010-08-21 12:38:45BreamoreBoysetnosy: + r.david.murray

versions: + Python 3.2, - Python 2.7
2009-02-16 01:01:21ajaksu2setstage: test needed
type: enhancement
versions: + Python 2.7, - Python 2.3
2005-03-13 16:11:46thervecreate