Skip to content

Commit 0e84fbe

Browse files
committed
Disable CSS sanitization in djangocms-text-ckeditor
The library used by djangocms-text-ckeditor is html5lib. It's deprecated and outdated. This should be fine because: - We have a CSP in place - Our editors are trusted (is_staff) I know there are CSS shenanigans, but we need the flexibility of custom styles.
1 parent 5462cd5 commit 0e84fbe

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fragdenstaat_de/settings/base.py

+14
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,20 @@ def three_days_ago_but_not_sundays(date):
302302
"sandbox",
303303
"style",
304304
)
305+
306+
# WARNING: We are monkey patching to not sanitize CSS
307+
# The used html5lib CSS Sanitizer is deprecated, outdated
308+
def _monkey_patch_css_sanitizer():
309+
# Do not sanitize CSS
310+
def sanitize_css(self, style):
311+
return style
312+
313+
from djangocms_text_ckeditor.sanitizer import TextSanitizer
314+
315+
TextSanitizer.sanitize_css = sanitize_css
316+
317+
_monkey_patch_css_sanitizer()
318+
305319
TEXT_ADDITIONAL_PROTOCOLS = ("bank",)
306320

307321
CKEDITOR_SETTINGS = {

0 commit comments

Comments
 (0)