]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-135528: Support more second-level domain names in http.cookiejar (#135820)
authorWeilin Du <108666168+LamentXU123@users.noreply.github.com>
Wed, 29 Apr 2026 11:33:51 +0000 (19:33 +0800)
committerGitHub <noreply@github.com>
Wed, 29 Apr 2026 11:33:51 +0000 (11:33 +0000)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Lib/http/cookiejar.py
Misc/NEWS.d/next/Library/2025-06-22-16-29-10.gh-issue-135528.Rt_QhR.rst [new file with mode: 0644]

index 68cf16c93cc1c83b5fb54d79a09bde1d18f22578..13e5b104a81ea2b6ca4021095609cc8afcfbfe34 100644 (file)
@@ -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 (file)
index 0000000..ab38555
--- /dev/null
@@ -0,0 +1 @@
+:mod:`http.cookiejar`: add "tv", "or", "nom", "sch", and "web" to the default list of supported country code second-level domains.