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

前端 未结 5 2089
逝去的感伤
逝去的感伤 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 18:58

    Yes, it is still valid.

    Filtering is not about preventing security vulnerabilities, it's about not populating your database with garbage. If you're expecting a date, make sure it at least looks like a date prior to storing it.

    Escaping output is about preventing security vulnerabilities (namely XSS or Cross Site Scripting).

    So yes, both are quite important and are totally unrelated to SQL Injection (although a fair number of developers still confuse filtering with escaping for SQL queries and hence can still be subject to vulnerabilities)...

提交回复
热议问题