Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit 586c18a

Browse files
Merge pull request #533 from diwash007/align
Allow CSS properties on bleach.clean
2 parents d823ba7 + 8c516bb commit 586c18a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

gsoc/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import json
66
import bleach
77
from urllib.parse import urljoin
8+
from bleach.css_sanitizer import CSSSanitizer
89

910
from bs4 import BeautifulSoup
1011
from django.db.models.deletion import PROTECT
@@ -166,12 +167,12 @@ def get_root_comments(self):
166167

167168

168169
def save(self, *args, **kwargs):
170+
css_sanitizer = CSSSanitizer(allowed_css_properties=settings.BLEACH_ALLOWED_STYLES)
169171
tags = settings.BLEACH_ALLOWED_TAGS
170172
attrs = bleach.sanitizer.ALLOWED_ATTRIBUTES
171173
attrs.update(settings.BLEACH_ALLOWED_ATTRS)
172-
styles = settings.BLEACH_ALLOWED_STYLES
173174
self.lead_in = bleach.clean(
174-
self.lead_in, tags=tags, attributes=attrs
175+
self.lead_in, tags=tags, attributes=attrs, css_sanitizer=css_sanitizer
175176
)
176177
soup = BeautifulSoup(self.lead_in, "html5lib")
177178
for iframe_tag in soup.find_all("iframe"):

0 commit comments

Comments
 (0)