Skip to content

gh-82039: relax cookiejar.py case-sensitive regex for the inconsequential first line of the cookie file - #15673

Merged
serhiy-storchaka merged 10 commits into
python:mainfrom
globalshrug:fix-issue-37858-latest
Aug 11, 2026
Merged

gh-82039: relax cookiejar.py case-sensitive regex for the inconsequential first line of the cookie file#15673
serhiy-storchaka merged 10 commits into
python:mainfrom
globalshrug:fix-issue-37858-latest

Conversation

@globalshrug

@globalshrug globalshrug commented Sep 4, 2019

Copy link
Copy Markdown
Contributor

@the-knights-who-say-ni

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Our records indicate we have not received your CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

@globalshrug globalshrug changed the title 37858: relax cookiejar.py case-sensitive regex for the inconsequential first line of the cookie file bpo-37858: relax cookiejar.py case-sensitive regex for the inconsequential first line of the cookie file Sep 4, 2019
@globalshrug

Copy link
Copy Markdown
Contributor Author

Apologies if I'm being obtuse, but, my PR has been in the queue for 3.5 years. Is there anything I need to do to get this approved and merged in?

@arhadthedev arhadthedev added the stdlib Standard Library Python modules in the Lib/ directory label Feb 11, 2023
@bedevere-bot

This comment was marked as resolved.

@arhadthedev arhadthedev changed the title bpo-37858: relax cookiejar.py case-sensitive regex for the inconsequential first line of the cookie file gh-82039: relax cookiejar.py case-sensitive regex for the inconsequential first line of the cookie file Feb 11, 2023
@arhadthedev

Copy link
Copy Markdown
Member

@ashleyharvey Could you sign the new CLA by clicking not signed button in the cpython-cla-bot's message, please?

@globalshrug

Copy link
Copy Markdown
Contributor Author

@ashleyharvey Could you sign the new CLA by clicking not signed button in the cpython-cla-bot's message, please?

Done, I think? I got an internal server error multiple times but looking at the bot's comment above now, it says it's signed.

@globalshrug

Copy link
Copy Markdown
Contributor Author

Bump

@python python deleted a comment Apr 7, 2025
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 7, 2026
@serhiy-storchaka

Copy link
Copy Markdown
Member

GNU wget 1.25.0 writes # HTTP Cookie File, so the original motivation is gone, but it will not harm to make the check more lenient — files written by older versions are still around.

Please add re.ASCII. Without it re.IGNORECASE enables full Unicode case folding, so these match too:

>>> re.compile("#( Netscape)? HTTP Cookie File", re.I).match("# Netſcape HTTP Cookie File")  # U+017F
<re.Match object; span=(0, 27), match='# Netſcape HTTP Cookie File'>
>>> re.compile("#( Netscape)? HTTP Cookie File", re.I).match("# Netscape HTTP CooKie File")  # U+212A
<re.Match object; span=(0, 27), match='# Netscape HTTP CooKie File'>

LWPCookieJar.magic_re already uses re.ASCII.

Please also add a test. test_bad_magic only covers rejection, so nothing would catch a regression here.

@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes and removed stale Stale PR or inactive for long period of time. labels Aug 10, 2026

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this PR is so old, there is not much chance to get a quick response from the original author, so I implemented my suggestions myself. LGTM now. Thank you @globalshrug for your contribution.

@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) August 11, 2026 16:37
@serhiy-storchaka
serhiy-storchaka merged commit 1cf7d89 into python:main Aug 11, 2026
55 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @globalshrug for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Aug 11, 2026

Copy link
Copy Markdown

GH-155580 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Aug 11, 2026
@bedevere-app

bedevere-app Bot commented Aug 11, 2026

Copy link
Copy Markdown

GH-155581 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 11, 2026
@bedevere-app

bedevere-app Bot commented Aug 11, 2026

Copy link
Copy Markdown

GH-155582 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Aug 11, 2026
serhiy-storchaka added a commit that referenced this pull request Aug 11, 2026
…nsequential first line of the cookie file (GH-15673) (GH-155582)

(cherry picked from commit 1cf7d89)

Co-authored-by: globalshrug <machone@gmail.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this pull request Aug 11, 2026
…nsequential first line of the cookie file (GH-15673) (GH-155581)

(cherry picked from commit 1cf7d89)

Co-authored-by: globalshrug <machone@gmail.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stdlib Standard Library Python modules in the Lib/ directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants