Patch #1483395: add new TLDs to cookielib

This commit is contained in:
Georg Brandl 2006-05-07 20:44:34 +00:00
parent 0901965134
commit e58334ae9e
1 changed files with 7 additions and 4 deletions

View File

@ -974,15 +974,18 @@ def set_ok_domain(self, cookie, request):
req_host, erhn = eff_request_host(request) req_host, erhn = eff_request_host(request)
domain = cookie.domain domain = cookie.domain
if self.strict_domain and (domain.count(".") >= 2): if self.strict_domain and (domain.count(".") >= 2):
# XXX This should probably be compared with the Konqueror
# (kcookiejar.cpp) and Mozilla implementations, but it's a
# losing battle.
i = domain.rfind(".") i = domain.rfind(".")
j = domain.rfind(".", 0, i) j = domain.rfind(".", 0, i)
if j == 0: # domain like .foo.bar if j == 0: # domain like .foo.bar
tld = domain[i+1:] tld = domain[i+1:]
sld = domain[j+1:i] sld = domain[j+1:i]
if (sld.lower() in ( if sld.lower() in ("co", "ac", "com", "edu", "org", "net",
"co", "ac", "gov", "mil", "int", "aero", "biz", "cat", "coop",
"com", "edu", "org", "net", "gov", "mil", "int") and "info", "jobs", "mobi", "museum", "name", "pro",
len(tld) == 2): "travel", "eu") and len(tld) == 2:
# domain like .co.uk # domain like .co.uk
debug(" country-code second level domain %s", domain) debug(" country-code second level domain %s", domain)
return False return False