Skip to content

Commit 51d735d

Browse files
committed
Add a sanitize_html template filter.
- Legacy-Id: 2238
1 parent 604497a commit 51d735d

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

ietf/idtracker/templatetags/ietf_filters.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ def format_textarea(value):
117117
Also calls keep_spacing."""
118118
return keep_spacing(linebreaksbr(escape(value).replace('&lt;b&gt;','<b>').replace('&lt;/b&gt;','</b>').replace('&lt;br&gt;','<br>')))
119119

120+
@register.filter(name='sanitize_html')
121+
def sanitize_html(value):
122+
"""Sanitizes an HTML fragment.
123+
This means both fixing broken html and restricting elements and
124+
attributes to those deemed acceptable. See ietf/utils/html.py
125+
for the details.
126+
"""
127+
from ietf.utils.html import sanitize_html
128+
return sanitize_html(value)
129+
130+
120131
# For use with ballot view
121132
@register.filter(name='bracket')
122133
def square_brackets(value):

0 commit comments

Comments
 (0)