ci post bug记录

       公司网站后台是用的ci框架,不过,这个框架确实给予了我不少“惊喜”,今天又发现一个,哎,坑爹。

前台向ci进行post请求,在请求数据里面包含了一个url数据,是一个非常长的url,大概400多个字节。ci获取到post请求数据时,会发现url数据被截取了,不仅被截取了,http后面的“:”都被替换成了空格符。真是个啃爹的事情。

        通过打log,发现ci 的REST_Controller.php文件中,对处理post的代码有xss_clean处理,代码如下

/**
	 * Retrieve a value from the POST request arguments.
	 *
	 * @param string $key The key for the POST request argument to retrieve
	 * @param boolean $xss_clean Whether the value should be XSS cleaned or not.
	 * @return string The POST argument value.
	 */
	public function post($key = NULL, $xss_clean = TRUE)
	{
		if ($key === NULL)
		{
			return $this->_post_args;
		}

		return array_key_exists($key, $this->_post_args) ? $this->_xss_clean($this->_post_args[$key], $xss_clean) : FALSE;
	}
ci的xss_clean过滤,会对较长的url进行拦截和处理,虽然没有在继续深入xss_clean如何进行处理较长url的,但是问题就节点找到就得想办法解决。

解决方法:跳过xss_clean处理:

源代码:

$data = $this->post('data');

更改之后的代码:

$data = $this->post()['data'];
这样就行了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值