Skip to content

Commit efa4c0e

Browse files
committed
Format
1 parent 3e7e1f0 commit efa4c0e

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

prose/fields.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,52 @@
66

77

88
ALLOWED_TAGS = [
9-
"p", "ul", "ol", "li", "strong", "em", "div", "span", "a",
10-
"blockquote", "pre", "figure", "figcaption", "br", "code",
11-
"h1", "h2", "h3", "h4", "h5", "h6",
12-
"picture", "source", "img",
9+
"p",
10+
"ul",
11+
"ol",
12+
"li",
13+
"strong",
14+
"em",
15+
"div",
16+
"span",
17+
"a",
18+
"blockquote",
19+
"pre",
20+
"figure",
21+
"figcaption",
22+
"br",
23+
"code",
24+
"h1",
25+
"h2",
26+
"h3",
27+
"h4",
28+
"h5",
29+
"h6",
30+
"picture",
31+
"source",
32+
"img",
1333
]
1434
ALLOWED_ATTRIBUTES = [
15-
"alt", "class", "id", "src", "srcset", "href", "media",
35+
"alt",
36+
"class",
37+
"id",
38+
"src",
39+
"srcset",
40+
"href",
41+
"media",
1642
]
1743

44+
1845
class RichTextField(models.TextField):
1946
def formfield(self, **kwargs):
2047
kwargs["widget"] = RichTextEditor
2148
return super().formfield(**kwargs)
2249

2350
def pre_save(self, model_instance, add):
2451
raw_html = getattr(model_instance, self.attname)
25-
sanitized_html = bleach.clean(raw_html, tags=ALLOWED_TAGS, attributes=ALLOWED_ATTRIBUTES)
52+
sanitized_html = bleach.clean(
53+
raw_html, tags=ALLOWED_TAGS, attributes=ALLOWED_ATTRIBUTES
54+
)
2655
return sanitized_html
2756

2857

0 commit comments

Comments
 (0)