ox.html.sanitize_html: fix existing tests

The backslashes need to be escaped to come out as literal backslashes in
the Python source code run by doctest.
This commit is contained in:
Will Thompson 2015-11-24 17:58:39 +00:00
parent 9b887120f7
commit 5448aec902

View file

@ -205,15 +205,15 @@ def sanitize_html(html, tags=None, global_attributes=[]):
>>> sanitize_html('<a href="http://foo.com" onmouseover="alert()">foo</a>') >>> sanitize_html('<a href="http://foo.com" onmouseover="alert()">foo</a>')
u'<a href="http://foo.com">foo</a>' u'<a href="http://foo.com">foo</a>'
>>> sanitize_html('<a href="javascript:alert()">foo</a>') >>> sanitize_html('<a href="javascript:alert()">foo</a>')
u'&lt;a href="javascript:alert()"&gt;foo' u'&lt;a href="javascript:alert()"&gt;foo&lt;/a&gt;'
>>> sanitize_html('[http://foo.com foo]') >>> sanitize_html('[http://foo.com foo]')
u'<a href="http://foo.com">foo</a>' u'<a href="http://foo.com">foo</a>'
>>> sanitize_html('<div style="direction: rtl">foo</div>') >>> sanitize_html('<div style="direction: rtl">foo</div>')
u'<div style="direction: rtl">foo</div>' u'<div style="direction: rtl">foo</div>'
>>> sanitize_html('<script>alert()</script>') >>> sanitize_html('<script>alert()</script>')
u'&lt;script&gt;alert()&lt;/script&gt;' u'&lt;script&gt;alert()&lt;/script&gt;'
>>> sanitize_html("'foo' < 'bar' && \"foo\" > \"bar\"") >>> sanitize_html("'foo' < 'bar' && \\"foo\\" > \\"bar\\"")
u'\'foo\' &lt; \'bar\' &amp;&amp; "foo" &gt; "bar"' u'\\'foo\\' &lt; \\'bar\\' &amp;&amp; "foo" &gt; "bar"'
>>> sanitize_html('<b>foo') >>> sanitize_html('<b>foo')
u'<b>foo</b>' u'<b>foo</b>'
>>> sanitize_html('<b>foo</b></b>') >>> sanitize_html('<b>foo</b></b>')