From: Weilin Du <108666168+LamentXU123@users.noreply.github.com> Date: Wed, 29 Apr 2026 11:33:51 +0000 (+0800) Subject: gh-135528: Support more second-level domain names in http.cookiejar (#135820) X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=4a5d25c26c01a04c0ddef1a0b00cb55cc835034f;p=thirdparty%2FPython%2Fcpython.git gh-135528: Support more second-level domain names in http.cookiejar (#135820) Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> --- diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py index 68cf16c93cc1..13e5b104a81e 100644 --- a/Lib/http/cookiejar.py +++ b/Lib/http/cookiejar.py @@ -1032,10 +1032,13 @@ class DefaultCookiePolicy(CookiePolicy): if j == 0: # domain like .foo.bar tld = domain[i+1:] sld = domain[j+1:i] - if sld.lower() in ("co", "ac", "com", "edu", "org", "net", - "gov", "mil", "int", "aero", "biz", "cat", "coop", - "info", "jobs", "mobi", "museum", "name", "pro", - "travel", "eu") and len(tld) == 2: + known_slds = ( + "co", "ac", "com", "edu", "org", "net", + "gov", "mil", "int", "aero", "biz", "cat", "coop", + "info", "jobs", "mobi", "museum", "name", "pro", + "travel", "eu", "tv", "or", "nom", "sch", "web", + ) + if sld.lower() in known_slds and len(tld) == 2: # domain like .co.uk _debug(" country-code second level domain %s", domain) return False diff --git a/Misc/NEWS.d/next/Library/2025-06-22-16-29-10.gh-issue-135528.Rt_QhR.rst b/Misc/NEWS.d/next/Library/2025-06-22-16-29-10.gh-issue-135528.Rt_QhR.rst new file mode 100644 index 000000000000..ab3855582c77 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-06-22-16-29-10.gh-issue-135528.Rt_QhR.rst @@ -0,0 +1 @@ +:mod:`http.cookiejar`: add "tv", "or", "nom", "sch", and "web" to the default list of supported country code second-level domains.