Best Practice: User generated HTML cleaning

前端 未结 4 1197
旧巷少年郎
旧巷少年郎 2021-01-02 22:47

I\'m coding a WYSIWYG editor width designMode=\"on\" on a iframe. The editor works fine and i store the code as is in the database.

Before outputing the html i need

4条回答
  •  星月不相逢
    2021-01-02 23:09

    If you are familiar with ASP .NET, just perform a Server.htmlencode() to convert special characters like < > to "& g t;" "&l t ;"

    In php, you can use htmlspecialchars() functions.

    Once the special characters are encoded, cross-site-scripting can be prevented.

提交回复
热议问题