rfc822 module bug?

Discussion in 'Python' started by Nemesis, Jul 30, 2005.

  1. Nemesis

    Nemesis Guest

    Hi all,
    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: <>)
    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 ",".

    Do you think that's a bug?
    Which is the most correct place where to file this bug?


    ¹ and looking at rfc822 par3.3 it should be correct:

    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

    --
    A pat on the back is only a few centimeters from a kick in the butt.

    |\ | |HomePage : http://nem01.altervista.org
    | \|emesis |XPN (my nr): http://xpn.altervista.org
    Nemesis, Jul 30, 2005
    #1
    1. Advertising

  2. On Sat, 30 Jul 2005 09:08:39 GMT, Nemesis <>
    declaimed the following in comp.lang.python:


    > Which is the most correct place where to file this bug?
    >

    Uh, with the software the created that DATE: header?

    Does RFC822 (or modern replacement) permit the lack of a space
    in that position? The spec is somewhat vague on spacing for dates, only
    indicating that the text day is optional and, if present, has a comma
    after it.

    5.1. SYNTAX

    date-time = [ day "," ] date time ; dd mm yy
    ; hh:mm:ss zzz

    --
    > ============================================================== <
    > | Wulfraed Dennis Lee Bieber KD6MOG <
    > | Bestiaria Support Staff <
    > ============================================================== <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.netcom.com/> <
    Dennis Lee Bieber, Jul 30, 2005
    #2
    1. Advertising

  3. Nemesis

    Cliff Wells Guest

    On Sat, 2005-07-30 at 09:08 +0000, Nemesis wrote:
    > Hi all,
    > 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: <>)
    > that has this Date field:
    >
    > Date: Tue,26 Jul 2005 13:14:27 GMT +0200


    My preferred date/time module is Gustavo Niemeyer's DateUtil module:

    https://moin.conectiva.com.br/DateUtil

    It parses an astounding number of date formats (I used it to parse the
    mess of dates and times provided by RSS feeds without a hitch).

    Regards,
    Cliff


    --

    http://www.develix.com :: Web applications and hosting :: Linux, PostgreSQL and Python specialists ::
    Cliff Wells, Jul 30, 2005
    #3
  4. Nemesis

    Tim Roberts Guest

    Nemesis <> wrote:
    >
    >Hi all,
    >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: <>)
    >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 ",".


    Fascinating. I've written a lot of e-mail programs, and I would have bet
    real money that this was not legal by either RFC822 or 2822, but the BNF
    certainly supports your assertion that this is valid.

    RFC1036, which gives the format for Usenet articles, includes the space in
    its "suggested" date format.

    >¹ and looking at rfc822 par3.3 it should be correct:
    >
    >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


    This is actually from RFC2822, but the point is the same.
    --
    - Tim Roberts,
    Providenza & Boekelheide, Inc.
    Tim Roberts, Aug 1, 2005
    #4
  5. Nemesis

    Nemesis Guest

    Mentre io pensavo ad una intro simpatica "Tim Roberts" scriveva:

    [rfc822 module bug]
    >>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 ",".

    >
    > Fascinating. I've written a lot of e-mail programs, and I would have bet
    > real money that this was not legal by either RFC822 or 2822, but the BNF
    > certainly supports your assertion that this is valid.

    [...]
    > This is actually from RFC2822, but the point is the same.


    Yes you are right of course.

    I think I'll submit this bug on the Python web-site.

    --
    "Sfugge un braccio a Pessotto." (Amedeo Goria)

    |\ | |HomePage : http://nem01.altervista.org
    | \|emesis |XPN (my nr): http://xpn.altervista.org
    Nemesis, Aug 1, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vladimir Litovka

    rfc822 regexp

    Vladimir Litovka, Feb 4, 2004, in forum: Perl
    Replies:
    1
    Views:
    777
  2. Darren Davison

    Dates from Strings in RFC822 format

    Darren Davison, Jul 23, 2003, in forum: Java
    Replies:
    2
    Views:
    1,513
    Shripathi Kamath
    Jul 23, 2003
  3. Rico

    JavaMail - RFC822

    Rico, Dec 23, 2004, in forum: Java
    Replies:
    4
    Views:
    1,418
  4. Tony Meyer

    RE: rfc822 module bug?

    Tony Meyer, Aug 2, 2005, in forum: Python
    Replies:
    0
    Views:
    384
    Tony Meyer
    Aug 2, 2005
  5. Nikolaus Schulz

    CRLF handling in the rfc822 module

    Nikolaus Schulz, May 21, 2006, in forum: Python
    Replies:
    0
    Views:
    321
    Nikolaus Schulz
    May 21, 2006
Loading...

Share This Page