zend framework sanitizing data

回眸只為那壹抹淺笑 提交于 2019-12-06 03:23:46

Probably the deal is about Zend_Controller_Request vs the Zend_Db. Request data are often put into the DB.

Request object does not escape anything. You may force it to do using filters, form filters or e.g. using the reflection technique described here:

Zend_Db queries are basically escaped like in other ORM's, like in PDO.

It does not automatically sanitize any request data. It cannot, because that requires it to know how to sanitize it, e.g. should $_GET['foo'] be string sanitized or for numbers? You have to tell it.

Whether you sanitize input manually in the respective Controller Actions or in an ActionHelper or automatically in a Controller Plugin or during bootstrap or with a mixture of these is up to you.

Use what is appropriate.

It definitely doesn't automatically sanitise your variables for you. You could do something like foreach or use array_map depending on the context, for example:

$_POST = array_map('mysql_real_escape_string', $_POST);

Ideally though you should treat each variable on a case by case basis. Personally i make a lot of use of PHP's filter_var for filtering and sanitizing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!