0

1. filters
I use PDO and wanted to know if it is still necessary potential escape characters like ('or'' =')
Already read a lot and some say that PDO is sufficient to prevent SQL Injection

2. BBCode
In a text field htmlspecialchars is the best option for not displaying html formatting?

Thanks

4

2 回答 2

1
  1. 仅 PDO 是不够的。准备好的语句或转义是正确的方法,无论您使用哪种访问方法。看到这个问题
  2. BBCode 不是 HTML。如果您使用的是 BBCode,则不需要htmlspecialchars
于 2013-11-07T04:18:13.070 回答
0

如果仍然需要潜在的转义字符,例如 ('or'' =')

事实上,转义“危险”字符(如or )从来没有任何用处。'or'=

PDO 足以防止 SQL 注入

PDO 本身不做任何保护。它是准备好的语句,它为查询中的每个动态数据使用占位符,确保安全。

对于 PDO 提供的预准备语句未涵盖的情况,请使用safeMysql或手动格式化并将查询部分列入白名单。

于 2013-11-07T06:52:09.507 回答