Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Lib/http/cookiejar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,10 +1032,13 @@ def set_ok_domain(self, cookie, request):
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 = (
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure hard code here would be a good idea.

  1. I think known_slds should be a global variable
  2. Maybe we can allow people to customize the slds

Copy link
Member

@picnixz picnixz Jun 15, 2025

Choose a reason for hiding this comment

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

It's already been there for a while, and it doesn't cost to have a local variable. I prefer treating customization as a separate FR (and it should rather be a class variable rather than a global one)

Copy link
Contributor Author

@LamentXU123 LamentXU123 Jun 16, 2025

Choose a reason for hiding this comment

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

Yes, I will work on this recently for a feature request. Good idea tho. I'm pretty interested. I will launch another issue with PR when I'm done.

Copy link
Contributor Author

@LamentXU123 LamentXU123 Jun 16, 2025

Choose a reason for hiding this comment

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

but I think we could just use this before the FR, since its been there for a while. And I'm not sure changing it to global var(or class var) and add customizing won't cause some strange bugs elsewhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and the updated list of second-domain will likely become the default one in customization. For now I think we could just update it as a hard code and change it after the FR is done

"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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:mod:`http.cookiejar`: add "tv", "or", "nom", "sch", and "web"
to the list of supported country code second-level domains.
Loading