cmlenz@113: # -*- coding: utf-8 -*-
cmlenz@113: #
cmlenz@113: # Copyright (C) 2006 Edgewall Software
cmlenz@113: # All rights reserved.
cmlenz@113: #
cmlenz@113: # This software is licensed as described in the file COPYING, which
cmlenz@113: # you should have received as part of this distribution. The terms
cmlenz@113: # are also available at http://markup.edgewall.org/wiki/License.
cmlenz@113: #
cmlenz@113: # This software consists of voluntary contributions made by many
cmlenz@113: # individuals. For the exact contribution history, see the revision
cmlenz@113: # history and logs, available at http://markup.edgewall.org/log/.
cmlenz@113:
cmlenz@113: import doctest
cmlenz@113: import unittest
cmlenz@113:
cmlenz@113: from markup.core import Stream
cmlenz@113: from markup.input import HTML, ParseError
cmlenz@113: from markup.filters import HTMLSanitizer
cmlenz@113:
cmlenz@113:
cmlenz@113: class HTMLSanitizerTestCase(unittest.TestCase):
cmlenz@113:
cmlenz@113: def test_sanitize_unchanged(self):
cmlenz@113: html = HTML('fo
o')
cmlenz@144: self.assertEquals(u'fo
o',
cmlenz@144: unicode(html.filter(HTMLSanitizer())))
cmlenz@113:
cmlenz@113: def test_sanitize_escape_text(self):
cmlenz@113: html = HTML('fo&')
cmlenz@144: self.assertEquals(u'fo&',
cmlenz@144: unicode(html.filter(HTMLSanitizer())))
cmlenz@113: html = HTML('<foo>')
cmlenz@144: self.assertEquals(u'<foo>',
cmlenz@144: unicode(html.filter(HTMLSanitizer())))
cmlenz@113:
cmlenz@113: def test_sanitize_entityref_text(self):
cmlenz@113: html = HTML('foö')
cmlenz@144: self.assertEquals(u'foƶ',
cmlenz@144: unicode(html.filter(HTMLSanitizer())))
cmlenz@113:
cmlenz@113: def test_sanitize_escape_attr(self):
cmlenz@113: html = HTML('