aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests/test_util.py
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2011-06-13 21:01:19 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-06-13 21:01:19 -0500
commita68ee5556e2cf78abd1e87546f8627ec07c1f89d (patch)
tree33184fa31aa036805102016aedb3d1774a88f9be /mediagoblin/tests/test_util.py
parent1e85d28e018e6dc0d4be9af82f221ac5450423bb (diff)
downloadmediagoblin-a68ee5556e2cf78abd1e87546f8627ec07c1f89d.tar.lz
mediagoblin-a68ee5556e2cf78abd1e87546f8627ec07c1f89d.tar.xz
mediagoblin-a68ee5556e2cf78abd1e87546f8627ec07c1f89d.zip
A super strict HTML cleaner method with mediocre tests.
Diffstat (limited to 'mediagoblin/tests/test_util.py')
-rw-r--r--mediagoblin/tests/test_util.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/mediagoblin/tests/test_util.py b/mediagoblin/tests/test_util.py
index 7b00a074..75e28aca 100644
--- a/mediagoblin/tests/test_util.py
+++ b/mediagoblin/tests/test_util.py
@@ -103,3 +103,22 @@ def test_locale_to_lower_lower():
# crazy renditions. Useful?
assert util.locale_to_lower_lower('en-US') == 'en-us'
assert util.locale_to_lower_lower('en_us') == 'en-us'
+
+
+def test_html_cleaner():
+ # Remove images
+ result = util.clean_html(
+ '<p>Hi everybody! '
+ '<img src="http://example.org/huge-purple-barney.png" /></p>\n'
+ '<p>:)</p>')
+ assert result == (
+ '<div>'
+ '<p>Hi everybody! </p>\n'
+ '<p>:)</p>'
+ '</div>')
+
+ # Remove evil javascript
+ result = util.clean_html(
+ '<p><a href="javascript:nasty_surprise">innocent link!</a></p>')
+ assert result == (
+ '<p><a href="">innocent link!</a></p>')