How to find if String contains html data?

后端 未结 7 2341
遇见更好的自我
遇见更好的自我 2020-12-15 18:13

How do I find if a string contains HTML data or not? The user provides input via web interface and it\'s quite possible he could have used either a simple text or used HTML

7条回答
  •  天涯浪人
    2020-12-15 18:58

    If you don't want the user to have HTML in their input, you can replace all '<' characters with their HTML entity equivalent, '& lt;' and all '>' with '& gt;' (no spaces between & and g)

提交回复
热议问题