Home  >  Q&A  >  body text

python - Markdown编辑器服务器处理最佳实践

在自己的工程中使用了开源的EpicEditor,一种Markdown编辑器。但是从Markdown编辑器获取的内容在保持到MySQL数据库之前,应该要做一些过滤动作吧。比如引用第三方资源(JS/CSS/iframe),标签转义,避免SQL注入攻击等。

是否有最佳实践?是否有开源的组件可用?

黄舟黄舟2717 days ago386

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-04-18 09:47:48

    I haven’t found any open source components, but a brief discussion on this issue can be found here. To prevent xss
    sql injection, you should use strict input filtering, advanced database connection classes, and ORM to prevent it.

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 09:47:48

    I have never used this open source editor. I don’t know whether the content you send to the server is markdown syntax content or markdown-translated html.
    For the latter, you can use Bleach to clean html tags
    for example:

    allowed_tags = ['a', 'p', 'ul', 'li', 'h1']
    new_html = bleach.linkify(bleach.clean(u"value html string",tags=allowed_tags, strip=True))

    Portal: http://bleach.readthedocs.io/...

    reply
    0
  • Cancelreply