GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Make join_header_words() more similar to the original · Issue #130631 · python/cpython

Make join_header_words() more similar to the original #130631

New issue
Copy link
New issue
Copy link
Closed
Closed
Make join_header_words() more similar to the original#130631
Copy link
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@serhiy-storchaka
serhiy-storchaka
opened on Feb 27, 2025
Issue body actions

Currently http.cookiejar.join_header_words() uses re.search(r"^\w+$", v) to check whether the value can be represented as a token, unquoted. There are some red flags here:

  1. \w looks arbitrary. And it is. The original Perl implementation (it is now in HTTP::Headers::Util) uses a set of characters documented in the split_header_words() docstring. On one side, it allows more characters (like "." or "-") be unquoted, on other hand, it requires quoting non-ASCII letters and digits.
  2. $ matches not only the end of the string, but also a position just before \n. So this pattern does not work for value containing \n. I do not know whether such values are supported at higher level, but currently that code is prone to header injection.
  3. Using search() with anchors at both ends for testing the whole string is very outdated, this patterns precedes the current re module. First, match() was added to testing the match from beginning, and later fullmatch() was added for testing the whole string.

Linked PRs

  • gh-130631: Make join_header_words() more similar to the original Perl version #130632
  • [3.13] gh-130631: Make join_header_words() more similar to the original Perl version (GH-130632) #132303

Activity

  1. serhiy-storchaka
    added
    3.12only security fixesonly security fixes
    3.13only security fixesonly security fixes
    3.14bugs and security fixesbugs and security fixes
    on Feb 27, 2025
  2. serhiy-storchaka
    added this to Cookies issues 🍪on Feb 27, 2025
  3. serhiy-storchaka
    added a commit that references this issue on Feb 27, 2025

    pythongh-130631: Make join_header_words() more similar to the origina…

    c075088
  4. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Feb 28, 2025
  5. serhiy-storchaka
    added 3 commits that reference this issue on Apr 9, 2025

    gh-130631: Make join_header_words() more similar to the original Perl…

    7ebbd27

    [3.13] pythongh-130631: Make join_header_words() more similar to the …

    d6c5ce3

    [3.13] gh-130631: Make join_header_words() more similar to the origin…

    8e97bd7
  6. serhiy-storchaka
    closed this as completedon Apr 9, 2025
  7. github-project-automation
    moved this to Done in Cookies issues 🍪on Apr 9, 2025
  8. serhiy-storchaka
    removed
    3.12only security fixesonly security fixes
    on Apr 9, 2025
  9. cjwatson
    added a commit that references this issue on May 26, 2025

    Fix CookieTests following fix for CPython #130631

    0c1cd4b
  10. dcermak
    added 2 commits that reference this issue on Jul 1, 2025

    tests: Fix cookie test compatibility with Python 3.13.4+

    eb54edc

    tests: Fix cookie test compatibility with Python 3.13.4+

    a853450
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.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • Cookies issues 🍪
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.