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: rfc822 module, bug in parsedate_tz
Type: Stage:
Components: Extension Modules Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, nemesis_xpn
Priority: normal Keywords:

Created on 2005-08-01 13:56 by nemesis_xpn, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg25919 - (view) Author: nemesis (nemesis_xpn) Date: 2005-08-01 13:56
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
msg25920 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-01-22 21:10
Fixed in rev. 53522, 53523 (2.5).
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42235
2005-08-01 13:56:51nemesis_xpncreate