[New-bugs-announce] [issue34951] cookielib/cookiejar cookies' Expires date parse fails with long month names

Alberto Moral report at bugs.python.org
Wed Oct 10 04:05:41 EDT 2018


New submission from Alberto Moral <alb_moral at yahoo.es>:

http.cookiejar (cookielib, for python2.*) does not parse some cookies' Expires date.

For  example: "Friday, 1-August-1997 00:00:00 GMT" does not work (while: "Fri, 01 Aug 1997 00:00:00 GMT" works fine)

This is basically due to long names of months (it is compared with MONTHS_LOWER: list of 3-letter months). So, I propose a small change in the definition of LOOSE_HTTP_DATE_RE (see fifth line):

LOOSE_HTTP_DATE_RE = re.compile(
    r"""^
    (\d\d?)            # day
       (?:\s+|[-\/])
    (\w{3})\w*         # month (3 first letters only)
    ...

Instead of:
LOOSE_HTTP_DATE_RE = re.compile(
    r"""^
    (\d\d?)            # day
       (?:\s+|[-\/])
    (\w+)              # month
    ...

I've tested only http.cookiejar (python 3.6), but I suposse the same change will work on cookielib

Thanks in advance

----------
components: Library (Lib)
messages: 327461
nosy: alb_moral
priority: normal
severity: normal
status: open
title: cookielib/cookiejar cookies' Expires date parse fails with long month names
type: behavior
versions: Python 2.7, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34951>
_______________________________________


More information about the New-bugs-announce mailing list