Skip to content

Commit

Permalink
Refactor call to bleach.clean() into it's own function
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Nov 7, 2022
1 parent ced89ee commit a54cbbf
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tcms/core/templatetags/extra_filters.py
Expand Up @@ -17,6 +17,14 @@ def is_list(variable):
return isinstance(variable, list)


def bleach_input(input_html):
return bleach.clean(
input_html,
markdown_tags + print_tags + ["del", "s"],
{**markdown_attrs, **print_attrs},
)


@register.filter(name="markdown2html")
def markdown2html(md_str):
"""
Expand All @@ -37,11 +45,7 @@ def markdown2html(md_str):
],
)

html = bleach.clean(
rendered_md,
markdown_tags + print_tags + ["del", "s"],
{**markdown_attrs, **print_attrs},
)
html = bleach_input(rendered_md)
return mark_safe(html) # nosec:B703:B308:blacklist


Expand Down

0 comments on commit a54cbbf

Please sign in to comment.