escape_html bulletproofing

pull/81/head
Chris Caron 6 years ago
parent 268d11f181
commit 741d244c5a

@ -24,6 +24,7 @@
# THE SOFTWARE.
import re
import six
import logging
from time import sleep
from datetime import datetime
@ -199,9 +200,8 @@ class URLBase(object):
Returns:
str: The escaped html
"""
if not html:
# nothing more to do; return object as is
return html
if not isinstance(html, six.string_types) or not html:
return ''
# Escape HTML
escaped = sax_escape(html, {"'": "'", "\"": """})

@ -196,6 +196,11 @@ def test_notify_base():
'/path/?name=Dr%20Disrespect', unquote=True) == \
['path', '?name=Dr', 'Disrespect']
# Give nothing, get nothing
assert NotifyBase.escape_html("") == ""
assert NotifyBase.escape_html(None) == ""
assert NotifyBase.escape_html(object()) == ""
# Test quote
assert NotifyBase.unquote('%20') == ' '
assert NotifyBase.quote(' ') == '%20'

Loading…
Cancel
Save