Check DeniedInstallOrigin against hostname and not netloc (#18665)
This commit is contained in:
Родитель
65276ad735
Коммит
b5e084fddc
|
@ -1191,7 +1191,7 @@ class DeniedInstallOrigin(ModelBase):
|
|||
denied = set()
|
||||
denied_install_origins = cls.objects.all()
|
||||
for origin in install_origins:
|
||||
hostname = InstallOrigin.punycode(urlparse(origin).netloc)
|
||||
hostname = InstallOrigin.punycode(urlparse(origin).hostname or '')
|
||||
for denied_origin in denied_install_origins:
|
||||
if fnmatch(hostname, denied_origin.hostname_pattern) or (
|
||||
denied_origin.include_subdomains
|
||||
|
|
|
@ -1987,6 +1987,12 @@ class TestDeniedInstallOrigin(TestCase):
|
|||
['https://foo.com', 'https://examplé.com']
|
||||
) == {'https://examplé.com'}
|
||||
|
||||
def test_find_denied_origins_with_port(self):
|
||||
DeniedInstallOrigin.objects.create(hostname_pattern='example.com')
|
||||
assert DeniedInstallOrigin.find_denied_origins(
|
||||
['https://foo.com', 'https://example.com:8888']
|
||||
) == {'https://example.com:8888'}
|
||||
|
||||
def test_find_denied_origins_multiple_matches(self):
|
||||
DeniedInstallOrigin.objects.create(hostname_pattern='example.com')
|
||||
assert DeniedInstallOrigin.find_denied_origins(
|
||||
|
|
Загрузка…
Ссылка в новой задаче