gh-128982: Revert "#128982: Substitute regular expression in http.cookiejar.join_header_words for an efficient alternative (GH-128983)" and add tests (GH-130584)

* Revert "gh-128982: Substitute regular expression in `http.cookiejar.join_header_words` for an efficient alternative (GH-128983)"

This reverts commit 56e1900681.

* Add tests
This commit is contained in:
Petr Viktorin 2025-02-26 15:42:39 +01:00 committed by GitHub
parent 56e1900681
commit 9e474a98af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 8 deletions

View file

@ -448,7 +448,7 @@ def join_header_words(lists):
attr = []
for k, v in pairs:
if v is not None:
if not v.isalnum() and '_' not in v:
if not re.search(r"^\w+$", v):
v = HEADER_JOIN_ESCAPE_RE.sub(r"\\\1", v) # escape " and \
v = '"%s"' % v
k = "%s=%s" % (k, v)