kopia lustrzana https://github.com/snarfed/bridgy-fed
/r/ redirect: handle bad URLs
fixes https://console.cloud.google.com/errors/detail/CJ30oPbsoqmI7QE;time=P30D?project=bridgy-federatedpull/691/head
rodzic
efdf84a023
commit
d7a51916ad
|
@ -60,7 +60,10 @@ def redir(to):
|
|||
if not util.is_web(to):
|
||||
error(f'Expected fully qualified URL; got {to}')
|
||||
|
||||
to_domain = urllib.parse.urlparse(to).hostname
|
||||
try:
|
||||
to_domain = urllib.parse.urlparse(to).hostname
|
||||
except ValueError as e:
|
||||
error(f'Invalid URL {to} : {e}')
|
||||
|
||||
# check conneg
|
||||
accept_as2 = False
|
||||
|
|
|
@ -65,6 +65,10 @@ class RedirectTest(testutil.TestCase):
|
|||
got = self.client.get(r'/r/https://v2.jacky.wtf\"')
|
||||
self.assertEqual(404, got.status_code)
|
||||
|
||||
def test_redirect_url_parse_value_error(self):
|
||||
got = self.client.get(r'/r/https:/[DOMAIN]/')
|
||||
self.assertEqual(400, got.status_code)
|
||||
|
||||
def test_as2(self):
|
||||
self._test_as2(as2.CONTENT_TYPE)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue