一次$_REQUEST的count参数异常BUG排查
2016-07-13 23:56
513 查看
由于360的PHP开发使用的是QFrame框架,然后对参数进行安全过滤时候调用了
$count= $this->getParam('count');方法,而该方法调用了QFrame的QFrameHttp类。
说白了,我们除了$_GET $_POST外,$_REQUEST默认情况下包含了 $_GET,$_POST 和 $_COOKIE 的数组。以后尽量少使用$_REQUEST
/**
* 带参数过滤功能的getParam,如果参数是数组,则递归过滤
*
* @param string $key 参数名
* @param multitype $default 默认值
* @param boolean $filter 是否过滤
* @access public
* @return mixed 参数变量值
*/
public function getParam($key = null, $default = null, $filter = true)
{
$value = parent::getParam($key, $default);
if ($filter) {
$value = $this->filterParam($value);
}
return $value;
}
/**
* 过滤参数中的字符串,如果参数是数组,则递归过滤
*
* @param mixed $value 输入参数
* @access public
* @return mixed 过滤后的参数
*/
public function filterParam($value)
{
if (is_string($value)) {
$value = htmlspecialchars($value, ENT_QUOTES);
} elseif (is_array($value)) {
$items = array();
foreach ($value as $index => $item) {
$items[$index] = $this->filterParam($item);
}
$value = $items;
}
return $value;
}
$count= $this->getParam('count');方法,而该方法调用了QFrame的QFrameHttp类。
说白了,我们除了$_GET $_POST外,$_REQUEST默认情况下包含了 $_GET,$_POST 和 $_COOKIE 的数组。以后尽量少使用$_REQUEST
/**
* 带参数过滤功能的getParam,如果参数是数组,则递归过滤
*
* @param string $key 参数名
* @param multitype $default 默认值
* @param boolean $filter 是否过滤
* @access public
* @return mixed 参数变量值
*/
public function getParam($key = null, $default = null, $filter = true)
{
$value = parent::getParam($key, $default);
if ($filter) {
$value = $this->filterParam($value);
}
return $value;
}
/**
* 过滤参数中的字符串,如果参数是数组,则递归过滤
*
* @param mixed $value 输入参数
* @access public
* @return mixed 过滤后的参数
*/
public function filterParam($value)
{
if (is_string($value)) {
$value = htmlspecialchars($value, ENT_QUOTES);
} elseif (is_array($value)) {
$items = array();
foreach ($value as $index => $item) {
$items[$index] = $this->filterParam($item);
}
$value = $items;
}
return $value;
}
相关文章推荐
- 在win7上安装ubuntu12.04双系统(uefi主板)
- F - Longest Ordered Subsequence
- UGUI之修改Text字间距
- Easyui 一些应用
- webpack + vue.js + vue route
- 瀑布流UICollectionViewFlowLayout/UICollectionViewLayout
- LeetCode 374. Guess Number Higher or Lower
- 详解Autolayout 设置UITableViewCell 高度问题
- 334. Increasing Triplet Subsequence
- UItableView动态刷新数据 --------->>>组、行动态加载
- leetcode之Guess Number Higher or Lower
- NSOperationQueue
- SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and <0.5MB model size
- iOS开发中的错误整理,iOS9之后的UIWindow(TopWindow)以及UIWindow与statusBar的关系
- $.ajax和vue-resource实现OAuth
- [leetcode]95. Unique Binary Search Trees II
- IOS中UIScrollView的详细使用
- Handler Looper MessageQueue
- QueryCache那些事
- LeetCode:Guess Number Higher or Lower