From 6d29db35c714fe52854a5b2e4002403150da1954 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Perrin?= Date: Sat, 12 Nov 2016 10:41:39 +0000 Subject: [PATCH] Limit tags from tinymce and use strip in bleach rather than replace --- djsite/settings_common.py | 1 + quotes/localmodels.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/djsite/settings_common.py b/djsite/settings_common.py index 101d833..6eed00b 100644 --- a/djsite/settings_common.py +++ b/djsite/settings_common.py @@ -99,4 +99,5 @@ TINYMCE_DEFAULT_CONFIG = { 'theme_advanced_buttons2' : '', 'theme_advanced_buttons3' : "", 'plugins': 'table', + 'valid_elements': 'a|b|strong|u|i|em|ul|ol|li|p|br' } diff --git a/quotes/localmodels.py b/quotes/localmodels.py index c09f771..691ea8c 100644 --- a/quotes/localmodels.py +++ b/quotes/localmodels.py @@ -2,7 +2,8 @@ import tinymce.models import bleach def valid_html(value): - return bleach.clean(value, bleach.ALLOWED_TAGS + ['p', 'br']) + return bleach.clean(value, bleach.ALLOWED_TAGS + ['p', 'br'], + strip=True, strip_comments=True) class HTMLField(tinymce.models.HTMLField): def pre_save(self, model_instance, add): -- 2.43.0