no inserting html tags into questions anymore

This commit is contained in:
mst 2024-11-26 15:11:13 +03:00
parent 9c9970b930
commit b7cb3f8247

View file

@ -420,11 +420,11 @@ def renderMarkdown(text):
'hr', 'hr',
'img' 'img'
] ]
allowed_attrs = { # allowed_attrs = {
'a': 'href', # 'a': 'href',
'button': 'class', # 'button': 'class',
'img': ['src', 'width', 'height', 'alt', 'class', 'loading', 'title'] # # 'img': ['src', 'width', 'height', 'alt', 'class', 'loading', 'title']
} # }
# hard_wrap=True means that newlines will be # hard_wrap=True means that newlines will be
# converted into <br> tags # converted into <br> tags
# #
@ -437,10 +437,10 @@ def renderMarkdown(text):
plugins=plugins, plugins=plugins,
hard_wrap=True hard_wrap=True
) )
html = md(text) cleaner = Cleaner(tags=allowed_tags)
cleaner = Cleaner(tags=allowed_tags, attributes=allowed_attrs) clean_text = cleaner.clean(text)
clean_html = cleaner.clean(html) html = md(clean_text)
return Markup(clean_html) return Markup(html)
def generateMetadata(question=None, answer=None): def generateMetadata(question=None, answer=None):
metadata = { metadata = {