def test_script_tags_get_removed_from_html_content(self): self.assertEqual(clean_html_script("<script></script>"), "") self.assertEqual( clean_html_script( "<script src=\"https://www.googleorsomething\"></script>"), "") self.assertEqual( clean_html_script( "<script src=\"https://www.googleorsomething\">There's some stuff in between here too </script>" ), "") self.assertEqual( clean_html_script( "<script src=\"https://www.googleorsomething\">There's some stuff in between here too </script>There should be some stuff here." ), "There should be some stuff here.") self.assertEqual(clean_html_script("<b>A strong word</b>"), "<b>A strong word</b>") self.assertEqual( clean_html_script( '<h1 class="char Zinh U030C" data-text="̌">̌</h1>'), '<h1 class="char Zinh U030C" data-text="̌">̌</h1>') self.assertEqual( clean_html_script({ 'my_key': 1, 'my_value': "twenty_seven", }), "{'my_key': 1, 'my_value': 'twenty_seven'}") self.assertEqual(clean_html_script(1), "1")
def test_script_tags_get_removed_from_html_content(self): self.assertEquals(clean_html_script("<script></script>"), "") self.assertEquals(clean_html_script("<script src=\"https://www.googleorsomething\"></script>"), "") self.assertEquals(clean_html_script( "<script src=\"https://www.googleorsomething\">There's some stuff in between here too </script>"), "") self.assertEquals(clean_html_script( "<script src=\"https://www.googleorsomething\">There's some stuff in between here too </script>There should be some stuff here."), "There should be some stuff here.") self.assertEquals(clean_html_script("<b>A strong word</b>"), "<b>A strong word</b>") self.assertEquals(clean_html_script(u'<h1 class="char Zinh U030C" data-text="̌">̌</h1>'), u'<h1 class="char Zinh U030C" data-text="̌">̌</h1>') self.assertEquals(clean_html_script({ 'my_key': 1, 'my_value': "twenty_seven", }), "{'my_value': 'twenty_seven', 'my_key': 1}") self.assertEquals(clean_html_script(1), "1")
def save(self, commit=True): instance = super(PageForm, self).save(commit=False) if instance.html: instance.html = clean_html_script(instance.html) if instance.pk is None: instance.codename = self.cleaned_data['label'] page_container,_ = PageContainer.objects.get_or_create(object_id=instance.competition.id, content_type=ContentType.objects.get_for_model(instance.competition)) details_category = ContentCategory.objects.get(name="Learn the Details") instance.category = details_category instance.container = page_container if commit: instance.save() return instance