This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
djangocms-text-ckeditor/djangocms_text_ckeditor/tests/test_html.py

27 lines
978 B
Python

from django.test import TestCase
from django.test.utils import override_settings
from .. import html
from .. import settings
class HtmlSanitizerAdditionalProtocolsTests(TestCase):
def tearDown(self):
settings.TEXT_ADDITIONAL_PROTOCOLS = []
def test_default_protocol_escaping(self):
settings.TEXT_ADDITIONAL_PROTOCOLS = []
parser = html._get_default_parser()
text = html.clean_html('''<source src="rtmp://testurl.com/">''',
full=False,
parser=parser)
self.assertEqual('<source>', text)
def test_custom_protocol_enabled(self):
settings.TEXT_ADDITIONAL_PROTOCOLS = ('rtmp',)
parser = html._get_default_parser()
text = html.clean_html('''<source src="rtmp://testurl.com/">''',
full=False,
parser=parser)
self.assertEqual('''<source src="rtmp://testurl.com/">''', text)