Skip to content

CookieLib: MozillaCookieJar.py uses case-sensitive regex to validate cookies file #82039

Closed

Description

@ashleyharvey
BPO 37858
Nosy @ashleyharvey
PRs
  • gh-82039: relax cookiejar.py case-sensitive regex for the inconsequential first line of the cookie file #15673
  • [3.8] bpo-37858: relax cookiejar.py case-sensitive regex for the inconsequential first line of the cookie file (GH-15673) #15679
  • [3.7] bpo-37858: relax cookiejar.py case-sensitive regex for the inconsequential first line of the cookie file (GH-15673) #15680
  • 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 = None
    closed_at = None
    created_at = <Date 2019-08-14.20:14:54.883>
    labels = ['3.7', '3.8', 'type-bug', 'library', '3.9']
    title = 'CookieLib: MozillaCookieJar.py uses case-sensitive regex to validate cookies file'
    updated_at = <Date 2019-09-04.21:02:38.953>
    user = 'https://github.com/ashleyharvey'

    bugs.python.org fields:

    activity = <Date 2019-09-04.21:02:38.953>
    actor = 'ned.deily'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2019-08-14.20:14:54.883>
    creator = 'ashleyharvey'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37858
    keywords = ['patch']
    message_count = 2.0
    messages = ['349743', '349744']
    nosy_count = 1.0
    nosy_names = ['ashleyharvey']
    pr_nums = ['15673', '15679', '15680']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue37858'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']

    Linked PRs

    Activity

    1. ashleyharvey commented on Aug 14, 2019

      ashleyharveymannequin
      MannequinAuthor

      I'm on macOS 10.14.6, wget 1.20.3, python 2.7.

      Command line:
      $ wget --save-cookies cookies.txt --keep-session-cookies --post-data
      'username=myUserName&password=myPassword' --delete-after <url>

      Line 39 of _MozillaCookieJar.py (cookielib) shows it looking for 'magic_re = "#( Netscape)? HTTP Cookie File"' in order to validate the supplied cookies file. Unlike cURL, wget however, produces a cookies file that begins with "# HTTP cookie file". Note the lower-case c and f. I reported this as a bug to the wget team who looked for the spec to say that that line must follow a certain format and couldn't find any such mention. (See: https://savannah.gnu.org/bugs/?56755)

      The lack of upper-case c and f cause cookielib to choke and stop processing
      the cookies file, and so here I am reporting it as a bug that the regex is case-sensitive.

    2. added
      stdlib
      type-bug
      on Aug 14, 2019
    3. ned-deily commented on Aug 14, 2019

      @ned-deily
      Member

      (removing the macOS component since presumably this behavior is not platform-dependent)

    4. added
      3.7 (EOL)
      3.8 (EOL)
      3.9 (EOL)
      on Sep 4, 2019
    5. transferred this issue fromon Apr 10, 2022
    6. removed
      3.9 (EOL)
      3.8 (EOL)
      3.7 (EOL)
      on Feb 11, 2023
    7. added 3 commits that reference this issue on Aug 11, 2026
    8. added
      3.13
      3.14
      3.15
      3.16
      on Aug 11, 2026
    9. added a commit that references this issue on Aug 14, 2026
    10. added a commit that references this issue on Oct 10, 2026
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.133.143.153.16stdlibtype-bug

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions