Skip to content

Commit

Permalink
bug 605459, strip_html should be smart with None
Browse files Browse the repository at this point in the history
  • Loading branch information
davedash committed Oct 19, 2010
1 parent 4800d56 commit 3ee42c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/amo/helpers.py
Expand Up @@ -260,6 +260,9 @@ def strip_html(s, just_kidding=False):
"""Strips HTML. Confirm lets us opt out easily."""
if just_kidding:
return s

if not s:
return ''
else:
s = re.sub(r'<.*?>', '', smart_unicode(s, errors='ignore'))
return re.sub(r'<.*?>', '', s)
Expand Down
4 changes: 4 additions & 0 deletions apps/amo/tests/test_helpers.py
Expand Up @@ -26,6 +26,10 @@ def test_strip_html():
eq_('Hey Brother!', render('{{ "Hey <b>Brother!</b>"|strip_html }}'))


def test_strip_html_none():
eq_('', render('{{ a|strip_html }}', {'a': None}))
eq_('', render('{{ a|strip_html(True) }}', {'a': None}))

def test_strip_controls():
"""We want control codes like \x0c to disappear."""
eq_('I ove you', render('{{ "I \x0cove you"|strip_controls }}'))
Expand Down

0 comments on commit 3ee42c7

Please sign in to comment.