# HG changeset patch # User Brian Neal # Date 1445799296 18000 # Node ID 9b197dbba34bc99e9537769b5502fbed90ec7f52 # Parent 7167c489bcddef1115edd6be6d030b09cc7040ab Fix image_check so it doesn't choke on empty input. Issue #88. diff -r 7167c489bcdd -r 9b197dbba34b core/html.py --- a/core/html.py Sun Oct 25 13:28:19 2015 -0500 +++ b/core/html.py Sun Oct 25 13:54:56 2015 -0500 @@ -75,6 +75,10 @@ hosts. If None, USER_IMAGES_SOURCES from settings will be used as the whitelist. """ + html = html.strip() + if not html: + return True + if not allowed_hosts: allowed_hosts = ALLOWED_HOSTS diff -r 7167c489bcdd -r 9b197dbba34b core/tests/test_html.py --- a/core/tests/test_html.py Sun Oct 25 13:28:19 2015 -0500 +++ b/core/tests/test_html.py Sun Oct 25 13:54:56 2015 -0500 @@ -66,3 +66,11 @@ html = TEST_HTML.format(src1=url1, src2=url2) self.assertRaises(ImageCheckError, image_check, html, self.allowed_hosts) + + def test_empty_string(self): + result = image_check('') + self.assertTrue(result) + + def test_whitespace(self): + result = image_check('\r\n\r\n') + self.assertTrue(result)