/r: handle trailing garbage chars

fixes https://console.cloud.google.com/errors/CO-fpZfMq_6ktgE
pull/79/head
Ryan Barrett 2021-09-01 19:48:37 -07:00
rodzic e4d285523f
commit c6f0c417a0
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -48,7 +48,7 @@ def redir(to):
domains = set((util.domain_from_link(to),
urllib.parse.urlparse(to).hostname))
for domain in domains:
if MagicKey.get_by_id(domain):
if domain and MagicKey.get_by_id(domain):
logging.info(f'Found MagicKey for domain {domain}')
break
else:

Wyświetl plik

@ -39,6 +39,10 @@ class RedirectTest(testutil.TestCase):
self.assertEqual(301, got.status_code)
self.assertEqual('https://foo.com/bar', got.headers['Location'])
def test_redirect_trailing_garbage_chars(self):
got = self.client.get(r'/r/https://v2.jacky.wtf\"')
self.assertEqual(404, got.status_code)
def test_as2(self):
self._test_as2(common.CONTENT_TYPE_AS2)