Mercurial > public > sg101
changeset 985:9b197dbba34b
Fix image_check so it doesn't choke on empty input.
Issue #88.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 25 Oct 2015 13:54:56 -0500 |
parents | 7167c489bcdd |
children | 26de15fb5a80 |
files | core/html.py core/tests/test_html.py |
diffstat | 2 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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)