diff --git a/umap/tests/test_views.py b/umap/tests/test_views.py index 4f7933de..fb7f00bd 100644 --- a/umap/tests/test_views.py +++ b/umap/tests/test_views.py @@ -55,6 +55,11 @@ class TestsValidateProxyURL(TestCase): with self.assertRaises(AssertionError): validate_url(request) + def test_unkown_domain_raises(self): + request = self.buildRequest("http://xlkjdkjsdlkjfd.com") + with self.assertRaises(AssertionError): + validate_url(request) + class TestsProxy(TestCase): diff --git a/umap/views.py b/umap/views.py index eb52422a..7563041e 100644 --- a/umap/views.py +++ b/umap/views.py @@ -207,8 +207,11 @@ def validate_url(request): assert referer.hostname == local.hostname assert toproxy.hostname != "localhost" assert toproxy.netloc != local.netloc - # clean this when in python 3.4 - ipaddress = socket.gethostbyname(toproxy.hostname) + try: + # clean this when in python 3.4 + ipaddress = socket.gethostbyname(toproxy.hostname) + except: + raise AssertionError() assert not ipaddress.startswith('127.') assert not ipaddress.startswith('192.168.') return url