Skip to content

Commit

Permalink
Add tests for sanitizer.
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtraschke committed Jul 15, 2010
1 parent 5b5ae30 commit 8d28811
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion textile/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import textile
import re
from nose.tools import eq_, assert_true

from nose.plugins.skip import SkipTest

"""
('>>> import textile')
Expand Down Expand Up @@ -367,3 +367,25 @@ def testPre(self):
expect = textile.textile(test)

eq_(result, expect)

def testSanitize(self):
try:
import html5lib
except ImportError:
raise SkipTest()

test = "a paragraph of benign text"
result = "\t<p>a paragraph of benign text</p>"
expect = textile.Textile().textile(test, sanitize=True)
eq_(result, expect)

test = """<p style="width: expression(alert('evil'));">a paragraph of evil text</p>"""
result = '<p style="">a paragraph of evil text</p>'
expect = textile.Textile().textile(test, sanitize=True)
eq_(result, expect)

test = """<p>a paragraph of benign text<br />and more text</p>"""
result = '<p>a paragraph of benign text<br>and more text</p>'
expect = textile.Textile().textile(test, sanitize=True,
html_type='html')
eq_(result, expect)

0 comments on commit 8d28811

Please sign in to comment.