mirror of https://github.com/caronc/apprise
escape_html bulletproofing
parent
268d11f181
commit
741d244c5a
|
@ -24,6 +24,7 @@
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import six
|
||||||
import logging
|
import logging
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -199,9 +200,8 @@ class URLBase(object):
|
||||||
Returns:
|
Returns:
|
||||||
str: The escaped html
|
str: The escaped html
|
||||||
"""
|
"""
|
||||||
if not html:
|
if not isinstance(html, six.string_types) or not html:
|
||||||
# nothing more to do; return object as is
|
return ''
|
||||||
return html
|
|
||||||
|
|
||||||
# Escape HTML
|
# Escape HTML
|
||||||
escaped = sax_escape(html, {"'": "'", "\"": """})
|
escaped = sax_escape(html, {"'": "'", "\"": """})
|
||||||
|
|
|
@ -196,6 +196,11 @@ def test_notify_base():
|
||||||
'/path/?name=Dr%20Disrespect', unquote=True) == \
|
'/path/?name=Dr%20Disrespect', unquote=True) == \
|
||||||
['path', '?name=Dr', 'Disrespect']
|
['path', '?name=Dr', 'Disrespect']
|
||||||
|
|
||||||
|
# Give nothing, get nothing
|
||||||
|
assert NotifyBase.escape_html("") == ""
|
||||||
|
assert NotifyBase.escape_html(None) == ""
|
||||||
|
assert NotifyBase.escape_html(object()) == ""
|
||||||
|
|
||||||
# Test quote
|
# Test quote
|
||||||
assert NotifyBase.unquote('%20') == ' '
|
assert NotifyBase.unquote('%20') == ' '
|
||||||
assert NotifyBase.quote(' ') == '%20'
|
assert NotifyBase.quote(' ') == '%20'
|
||||||
|
|
Loading…
Reference in New Issue