What are the best practices for avoiding xss attacks in a PHP site

前端 未结 20 2601
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 02:34

I have PHP configured so that magic quotes are on and register globals are off.

I do my best to always call htmlentities() for anything I am outputing that is derive

20条回答
  •  甜味超标
    2020-11-22 03:17

    You should at least validate all data going into the database. And try to validate all data leaving the database too.

    mysql_real_escape_string is good to prevent SQL injection, but XSS is trickier. You should preg_match, stip_tags, or htmlentities where possible!

提交回复
热议问题