Is “filter input, escape output” still valid with PDO

前端 未结 5 2110
逝去的感伤
逝去的感伤 2020-12-16 18:34

I\'ve read this before \"filter input, escape output\" but is filtering input really needed when I use PDO with PHP? I thought with PDO I don\'t need to filter input because

5条回答
  •  一生所求
    2020-12-16 19:13

    Yes, it is escaping input, but not immediately like magic_quotes_gpc. Magic quotes is an awful approach to security. Vulnerabilities are highly dependent on how the tainted data is being used, you can never have 1 function that fixes everything all of the time. Also during the flow of the application there may be a case when another function undermines magic_quotes, such as stripslashes(), base64_decode(), urldecode(), htmlspecialchars_decode($var,ENT_QUOTES); and even substr().

    In short, you must always escape input at the time of use. pdo and adodb does this, and it does it perfectly.

提交回复
热议问题