在我的codeigniter配置中,我有$config['global_xss_filtering'] = TRUE;。在我的管理部分,我有一个ckeditor,它生成前端内容。
在编辑器中输入和放置的所有内容都可以正常工作,图像可以很好地显示,html可以正常工作。除了闪光灯。每当我切换到html模式并粘贴一段youtube代码时,代码就会被转义,并且代码会显示在首页上,而不是显示youtube电影。
如果我设置了$config['global_xss_filtering'] = FALSE;,youtube代码就会像应该的那样被传递。这是因为CI将“object”、“embed”等标记为"naughty“,因此进行了转义。
我如何绕过这个控制器方法的xss过滤?
发布于 2010-10-11 18:07:47
默认情况下将其关闭,然后在真正需要它的地方启用它。
例如,我为我的所有控制器关闭了它,然后为评论、页面等启用了它。
您可以做的一件事是创建一个类似于PyroCMS中的MY_Input (或CI 2中的MY_Security ),并用一个完全相同的副本覆盖xss_clean方法,去掉正则表达式中的object|embed|部分。
http://github.com/pyrocms/pyrocms/blob/master/system/pyrocms/libraries/MY_Security.php
这是一个地狱般的漫长的道路,但它是有效的。
也许我们可以创建一个配置选项,列出2.0的坏元素?
发布于 2015-02-22 20:33:27
我的情况是,我希望global_xss_filtering在默认情况下是打开的,但有时我需要$_POST (pst您可以对任何全局php数组执行此操作,例如$_GET...)数据作为从浏览器发送的原始数据,所以我的解决方案是:
< code >H117然后,每当我需要原始$_POST时,我都会执行以下操作:
全局$unsanitized_post;
print_r($unsanitized_post);
发布于 2014-11-21 11:48:52
在CodeIgniter 2.0中,最好的做法是覆盖核心CI库上的xss_clean,使用MY_Security.php将其放在应用程序/核心文件夹中,然后使用/应用程序/config.php
$config['xss_exclude_uris'] = array('controller/method');下面是MY_Security.php https://gist.github.com/slick2/39f54a5310e29c5a8387:
<?php
/**
* CodeIgniter version 2
* Note: Put this on your application/core folder
*/
class MY_Security extends CI_Security {
/**
* Method: __construct();
* magic
*/
function __construct()
{
parent::__construct();
}
function xss_clean($str, $is_image = FALSE)
{
$bypass = FALSE;
/**
* By pass controllers set in /application/config/config.php
* config.php
* $config['xss_exclude_uris'] = array('controller/method')
*/
$config = new CI_Config;
$uri = new CI_URI;
$uri->_fetch_uri_string();
$uri->_explode_segments();
$controllers_list = $config->item('xss_exclude_uris');
// we need controller class and method only
if (!empty($controllers_list))
{
$segments = array(0 => NULL, 1 => NULL);
$segments = $uri->segment_array();
if (!empty($segments))
{
if (!empty($segments[1]))
{
$action = $segments[0] . '/' . $segments[1];
}
else
{
$action = $segments[0];
}
if (in_array($action, $controllers_list))
{
$bypass = TRUE;
}
}
// we unset the variable
unset($config);
unset($uri);
}
if ($bypass)
{
return $str;
}
else
{
return parent::xss_clean($str, $is_image);
}
}
}https://stackoverflow.com/questions/3899777
复制相似问题