Escaping variables

后端 未结 4 1886
轻奢々
轻奢々 2020-12-10 21:11

I\'ve read that it\'s enough and even recommended to escape characters on the output, not on the input.

It could be easily applied to all get variables as they are n

4条回答
  •  借酒劲吻你
    2020-12-10 21:49

    1. whenever data is coming from user, sanitize it(take special attention if its storing in database.). So PDO with prepared statement is a must. What else you do is added bonus.

    2. Yes (opinions will differ here from person to person) for preventing sql injection (assuming you are using prepared statement). though I prefer storing the raw data in database even if it means sacrificing for some malicious XSS code may contain it. While outputting, take utmost care.

    3. No. use htmlpurifier (with a view that you are outputting from a database.)

提交回复
热议问题