I found that the function parsedate_tz of the rfc822
module has a bug (or at least I think so).
I found a usenet article (message-id:
<2714d.q75200@myg.winews.net>)
that has this Date field:
Date: Tue,26 Jul 2005 13:14:27 GMT +0200
It seems to be correct¹, but parsedate_tz is not able
to decode it, it
is confused by the absence of a space after the ",".
I studied the parsedate_tz code and the problem is on
its third line:
...
if not data:
return None
data = data.split()
...
After the split I have:
['Tue,26', 'Jul', '2005', '13:14:27', 'GMT', '+0200']
but "Tue," and "26" should be separated.
Of course parsedate_tz correctly decode the field if
you add a space after the ",".
A possible solution is to change the line n°863 of
rfc822.py (data=data.split()) with this one:
data=data.replace(",",", ").split()
it solves the problem and should not affect the normal
behaviour.
¹ and looking at rfc2822 par3.3 it should be correct,
the space after
the comma is not mandatory:
date-time = [ day-of-week "," ] date FWS
time [CFWS]
day-of-week = ([FWS] day-name) / obs-day-of-week
day-name = "Mon" / "Tue" / "Wed" / "Thu" /
"Fri" / "Sat" / "Sun"
date = day month year
|