diff --git a/cps/clean_html.py b/cps/clean_html.py index c687f1542..3436f43a5 100644 --- a/cps/clean_html.py +++ b/cps/clean_html.py @@ -35,7 +35,7 @@ def clean_string(unsafe_text, book_id=0): try: if bleach: allowed_tags = list(ALLOWED_TAGS) - allowed_tags.extend(["p", "span", "div", "pre", "br", "h1", "h2", "h3", "h4", "h5", "h6"]) + allowed_tags.extend(["p", "span", "div", "pre", "br", "h1", "h2", "h3", "h4", "h5", "h6", "img"]) safe_text = clean_html(unsafe_text, tags=set(allowed_tags)) else: safe_text = clean_html(unsafe_text) diff --git a/cps/jinjia.py b/cps/jinjia.py index cb51b2bc0..0b30f3b80 100644 --- a/cps/jinjia.py +++ b/cps/jinjia.py @@ -30,6 +30,7 @@ from uuid import uuid4 from flask import Blueprint, request, url_for, g from flask_babel import format_date from .cw_login import current_user +from .clean_html import clean_string as html_clean_string from . import constants, logger @@ -181,3 +182,9 @@ def contains_music(book_formats): if format.format.lower() in g.constants.EXTENSIONS_AUDIO: result = True return result + +@jinjia.app_template_filter('clean_string') +def clean_string(unsafe_text): + return html_clean_string(unsafe_text) + + diff --git a/cps/templates/basic_detail.html b/cps/templates/basic_detail.html index 1996497ba..dc8242536 100644 --- a/cps/templates/basic_detail.html +++ b/cps/templates/basic_detail.html @@ -74,7 +74,7 @@ {% if entry.comments|length > 0 and entry.comments[0].text|length > 0 %}

{{ _('Description:') }}

- {{ entry.comments[0].text|safe }} + {{ entry.comments[0].text|clean_string|safe }}
{% endif %} diff --git a/cps/templates/detail.html b/cps/templates/detail.html index 69ec460f7..164ac424d 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -284,7 +284,7 @@ {% if entry.comments|length > 0 and entry.comments[0].text|length > 0 %}

{{ _('Description:') }}

- {{ entry.comments[0].text|safe }} + {{ entry.comments[0].text|clean_string|safe }}
{% endif %} diff --git a/cps/templates/listenmp3.html b/cps/templates/listenmp3.html index 4ba6931e8..375a871b4 100644 --- a/cps/templates/listenmp3.html +++ b/cps/templates/listenmp3.html @@ -175,7 +175,7 @@ {% if entry.comments|length > 0 and entry.comments[0].text|length > 0%}

{{_('Description:')}}

- {{entry.comments[0].text|safe}} + {{entry.comments[0].text|clean_string|safe}}
{% endif %}