简体   繁体   English

CodeIgniter:对整个$ _POST数组使用带有XSS过滤功能的get_post

[英]CodeIgniter: Use get_post with XSS filtering on entire $_POST array

Is there an easier way than 有没有比这更简单的方法

foreach($_POST as $x=>$y){
  $arr[$x] = $this->input->get_post($y, TRUE);
}

to just have the entire $_POST array cleaned with CI's XSS filter. 用CI的XSS过滤器清理整个$ _POST数组。 Looking at the input library it seems though get_post() only accepts an individual variable rather than being able to clean the entire array and then return the array back. 查看输入库,尽管get_post()似乎只接受一个单独的变量,但无法清理整个数组,然后将数组返回。

Not sure if you want it globally, but if you do... from ze manual: 不知道是否要在全球范围内使用,但是如果需要...从ze手册:

If you want the filter to run automatically every time it encounters POST or COOKIE data you can enable it by opening your application/config/config.php file and setting this: 如果希望过滤器每次遇到POST或COOKIE数据时都自动运行,则可以通过打开application / config / config.php文件并设置以下内容来启用它:

$config['global_xss_filtering'] = TRUE;
$this->input->post(NULL, TRUE);

returns all POST items with XSS filter 使用XSS过滤器返回所有POST项目

$this->input->post();

returns all POST items without XSS filter 返回所有没有XSS过滤器的POST项目

The chosen answer for this is correct in a sense but the information is provided is not a suitable answer to the real problem which is XSS filtering in CI. 从某种意义上讲,为此选择的答案是正确的,但是提供的信息并不是针对实际问题(CI中的XSS过滤)的合适答案。

To further the comment by bobince some good reading at: 为了使bobince进一步评论,请阅读以下文章:

http://ponderwell.net/2010/08/codeigniter-xss-protection-is-good-but-not-enough-by-itself/ http://ponderwell.net/2010/08/codeigniter-xss-protection-is-good-but-not-enough-by-itself/

Either htmlspecialchars / htmlentities / urlencode on all output or go home. 在所有输出中使用htmlspecialchars / htmlentities / urlencode或返回首页。 CI's XSS filter uses a dated and broken blacklist technique that fails a lot of XSS attacks. CI的XSS过滤器使用过时且破损的黑名单技术,使许多XSS攻击失败。

Encode and validate. 编码和验证。 Always. 总是。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM