[Tracker-discuss] [issue667] cookielib/cookiejar cookies' expire date parse

Alberto Moral metatracker at psf.upfronthosting.co.za
Mon Oct 8 13:53:04 EDT 2018


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

http.cookiejar (cookielib, python2.*) does not parse some cookies' expire date. For  example: "Friday, 1-August-1997 00:00:00 GMT" (while: "Fri, 1-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 re's STRICT_DATE_RE and LOOSE_HTTP_DATE_RE:

STRICT_DATE_RE = re.compile(
    r"^[SMTWF][a-z][a-z]+, (\d\d) ([JFMASOND][a-z][a-z])[a-z]+ "
    r"(\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$", re.ASCII)

Instead of:

STRICT_DATE_RE = re.compile(
    r"^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) "
    r"(\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$", re.ASCII)


And:

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

----------
messages: 3546
nosy: alb_moral
priority: bug
status: unread
title: cookielib/cookiejar cookies' expire date parse

_______________________________________________________
PSF Meta Tracker <metatracker at psf.upfronthosting.co.za>
<http://psf.upfronthosting.co.za/roundup/meta/issue667>
_______________________________________________________


More information about the Tracker-discuss mailing list