diff --git a/wagtail/wagtailcore/rich_text.py b/wagtail/wagtailcore/rich_text.py index d4ac8d6561..60159ca5ca 100644 --- a/wagtail/wagtailcore/rich_text.py +++ b/wagtail/wagtailcore/rich_text.py @@ -127,9 +127,10 @@ class DbWhitelister(Whitelister): link_attrs['linktype'] = link_type tag.attrs.clear() tag.attrs.update(**link_attrs) - elif tag.name == 'div': - tag.name = 'p' else: + if tag.name == 'div': + tag.name = 'p' + super(DbWhitelister, cls).clean_tag_node(doc, tag) diff --git a/wagtail/wagtailcore/tests/test_dbwhitelister.py b/wagtail/wagtailcore/tests/test_dbwhitelister.py index 35e5b34b5e..3ab7868fa5 100644 --- a/wagtail/wagtailcore/tests/test_dbwhitelister.py +++ b/wagtail/wagtailcore/tests/test_dbwhitelister.py @@ -36,6 +36,13 @@ class TestDbWhitelister(TestCase): expected = '

OMG look at this video of a kitten:

' self.assertHtmlEqual(expected, output_html) + def test_div_conversion(self): + # DIVs should be converted to P, and all whitelist / conversion rules still applied + input_html = '

before

OMG look at this video of a kitten:

after

' + output_html = DbWhitelister.clean(input_html) + expected = '

before

OMG look at this video of a kitten:

after

' + self.assertHtmlEqual(expected, output_html) + def test_whitelist_hooks(self): # wagtail.tests.wagtail_hooks overrides the whitelist to permit
and input_html = '
I would put a tax on all people who stand in water.

- Gumby

'