开发者

Should I use both striptags() and htmlspecialchars() to prevent XSS?

开发者 https://www.devze.com 2023-03-31 07:26 出处:网络
Does this depend on if the input is going to be printed to the user? In my case I need to return the input back to the user (comment开发者_开发知识库s and bio).

Does this depend on if the input is going to be printed to the user? In my case I need to return the input back to the user (comment开发者_开发知识库s and bio).

Thanks!!!


htmlspecialchars() is enough to prevent XSS.

Strip tags removes tags but not special characters like " or ', so if you use strip_tags() you also have to use htmlspecialchars().

If you want users' comments to be displayed like they typed them, don't use strip_tags, use htmlspecialchars() only.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号