Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookie module does not parse date #40325

Closed
manlioperillo mannequin opened this issue Jun 2, 2004 · 4 comments
Closed

Cookie module does not parse date #40325

manlioperillo mannequin opened this issue Jun 2, 2004 · 4 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@manlioperillo
Copy link
Mannequin

manlioperillo mannequin commented Jun 2, 2004

BPO 964861
Nosy @akuchling
Files
  • cookie.txt: regex pattern for Cookie module
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/akuchling'
    closed_at = <Date 2004-06-06.11:09:53.000>
    created_at = <Date 2004-06-02.09:02:41.000>
    labels = ['library']
    title = 'Cookie module does not parse date'
    updated_at = <Date 2004-06-06.11:09:53.000>
    user = 'https://bugs.python.org/manlioperillo'

    bugs.python.org fields:

    activity = <Date 2004-06-06.11:09:53.000>
    actor = 'manlioperillo'
    assignee = 'akuchling'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2004-06-02.09:02:41.000>
    creator = 'manlioperillo'
    dependencies = []
    files = ['1292']
    hgrepos = []
    issue_num = 964861
    keywords = []
    message_count = 4.0
    messages = ['20971', '20972', '20973', '20974']
    nosy_count = 3.0
    nosy_names = ['akuchling', 'insomnike', 'manlioperillo']
    pr_nums = []
    priority = 'normal'
    resolution = 'wont fix'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue964861'
    versions = []

    @manlioperillo
    Copy link
    Mannequin Author

    manlioperillo mannequin commented Jun 2, 2004

    >>> sys.version
    '2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit
    (Intel)]'
    >>> sys.platform
    'win32'
    >>> sys.getwindowsversion()
    (5, 1, 2600, 2, '')

    Hi.
    The standard Cookie module does not parse date string.

    Here is and example:

    >>> import Cookie
    >>> s = 'Set-Cookie: key=value; path=/; expires=Fri,
    21-May-2004 10:40:51 GMT'
    >>> c = Cookie.BaseCookie(s)
    >>> print c
    Set-Cookie: key=value; expires=Fri,; Path=/;

    In the attached file I have reported the correct (I
    think) regex pattern.

    Thanks and Regards Manlio Perillo

    @manlioperillo manlioperillo mannequin closed this as completed Jun 2, 2004
    @manlioperillo manlioperillo mannequin assigned akuchling Jun 2, 2004
    @manlioperillo manlioperillo mannequin added the stdlib Python modules in the Lib dir label Jun 2, 2004
    @manlioperillo manlioperillo mannequin closed this as completed Jun 2, 2004
    @manlioperillo manlioperillo mannequin assigned akuchling Jun 2, 2004
    @manlioperillo manlioperillo mannequin added the stdlib Python modules in the Lib dir label Jun 2, 2004
    @insomnike
    Copy link
    Mannequin

    insomnike mannequin commented Jun 5, 2004

    Logged In: YES
    user_id=1057404

    This bug is in error; RFC2109 specifies the BNF grammar as:

    av-pairs = av-pair *(";" av-pair)
    av-pair = attr ["=" value] ;
    optional value
    attr = token
    value = word
    word = token | quoted-string

    If you surround the date in double quotes, as per the RFC,
    then the above works correctly.

    @akuchling
    Copy link
    Member

    Logged In: YES
    user_id=11375

    Closing as 'not a bug'. This decision could be reversed if there's some
    common application or software that returns cookies without quoting the
    date properly.

    @manlioperillo
    Copy link
    Mannequin Author

    manlioperillo mannequin commented Jun 6, 2004

    Logged In: YES
    user_id=1054957

    insomnike wrote that RFC2109 requires double quotes.
    This is right, but many servers follow the Netscape spec.

    Moreover (as I can see) the same Cookie module follow the
    Netscape date spec!

    >>> import Cookie
    >>> c = Cookie.SimpleCookie()
    >>> c['key'] = 'value'
    >>> c['key']['expires'] = 10
    >>> c.output()
    'Set-Cookie: key=value; expires=Sun, 06-Jun-2004 10:36:24 GMT;'
    >>> s = c.output()
    >>> nc = Cookie.SimpleCookie(s)
    >>> nc.output()
    'Set-Cookie: key=value; expires=Sun,;'

    Thanks and regards Manlio Perillo

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant