Markdown in Django XSS safe

后端 未结 2 1352
-上瘾入骨i
-上瘾入骨i 2021-01-15 02:30

I am using Markdown in an app to display a user biography. I want the user to be able to slightly format the biography, so I\'m letting them use the TinyMCE editor.

2条回答
  •  自闭症患者
    2021-01-15 02:57

    According to django.contrib.markup.templatetags.markup.markdown's docstrings:

    To enable safe mode, which strips raw HTML and only returns HTML generated by actual Markdown syntax, pass "safe" as the first extension in the list.

    This should work:

    {{ biography|markdown:"safe" }}
    

提交回复
热议问题