Fixing checkSameHost to work with IPv6 addresses

This commit is contained in:
Miroslav Stampar
2026-01-28 19:01:07 +01:00
parent 0ce9d4aeb7
commit fcd3eae668
3 changed files with 14 additions and 4 deletions

View File

@@ -4811,7 +4811,17 @@ def checkSameHost(*urls):
value = "http://%s" % value
return value
return all(re.sub(r"(?i)\Awww\.", "", _urllib.parse.urlparse(_(url) or "").netloc.split(':')[0]) == re.sub(r"(?i)\Awww\.", "", _urllib.parse.urlparse(_(urls[0]) or "").netloc.split(':')[0]) for url in urls[1:])
first = _urllib.parse.urlparse(_(urls[0]) or "").hostname or ""
first = re.sub(r"(?i)\Awww\.", "", first)
for url in urls[1:]:
current = _urllib.parse.urlparse(_(url) or "").hostname or ""
current = re.sub(r"(?i)\Awww\.", "", current)
if current != first:
return False
return True
def getHostHeader(url):
"""