Safe html in java

前端 未结 4 1580
陌清茗
陌清茗 2021-01-23 02:59

I have some input containing HTML like
etc. I need a way to escape only the \"bad\" HTML that exposes my si

相关标签:
4条回答
  • 2021-01-23 03:27

    You might want to just escape all html. If you want to have users be able to use basic html tags like <b> or <i> then you could just replace them with [b] and [i] (if your forum/whatever you're creating can use bbcode), then just replace all "<" and ">" with "&lt;" and "&gt;".

    0 讨论(0)
  • 2021-01-23 03:34

    Playframework 2 already offers a solution.

    the @Html() function filters bad html, which is really nice.

    I really love play2

    0 讨论(0)
  • 2021-01-23 03:36

    Google caja is a tool for making third party HTML, CSS and JavaScript safe to embed in your website.

    0 讨论(0)
  • 2021-01-23 03:38

    OWASP AntiSamy is a project for just that. If you need users to be able to submit structured text, look at markdown (imho a lot better than BBCode).

    0 讨论(0)
提交回复
热议问题