【问题标题】:CodeIgniter xss_clean issue with large amount of html [in firefox]大量 html 的 CodeIgniter xss_clean 问题 [在 Firefox 中]
【发布时间】:2014-11-10 12:30:57
【问题描述】:

我在控制台上收到以下错误:

<p>Severity: 8192</p>
<p>Message:  preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead</p>
<p>Filename: core/Security.php</p>
<p>Line Number: 512</p>

指的是核心/安全行 512 中的函数:

public function entity_decode($str, $charset='UTF-8'){
    if (stristr($str, '&') === FALSE)
    {
        return $str;
    }

    $str = html_entity_decode($str, ENT_COMPAT, $charset);
    $str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str);
    return preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str);
}

发生这种情况是因为我将大量 HTML(纯 HTML)插入到数据库中。

public function add($data){
    $this->security->xss_clean($data);
    $this->db->insert('covers', $data);

    return $this->db->insert_id();
}

如果我删除$this-&gt;security-&gt;xss_clean($data); 行,它会完美运行。

一个奇怪的事情是它可以在 Chrome 上运行,但是一旦我在 Firefox (v. 32.0.1) 上测试它就停止在 Chrome 上运行。在 Firefox 中测试并收到错误后,如果我转到 Chrome 并再次测试,我在 Chrome 中也遇到了同样的问题。

编辑:即使出现此错误,即使$this-&gt;security-&gt;xss_clean($data); 行打开,信息也会存储在数据库中,但警告会显示在控制台中。

【问题讨论】:

    标签: php html codeigniter google-chrome firefox


    【解决方案1】:

    在您的代码中使用 error_reporting(E_ALL &amp; ~E_NOTICE &amp; ~E_WARNING); 这将抑制错误

    【讨论】:

    • 好吧,我不想压制这个问题,而是想办法使用该功能preg_replace_callback
    【解决方案2】:

    解决了。

    我去了 Ellislab 支持,他们告诉我该功能已不再使用。 https://support.ellislab.com/bugs/detail/20646/the-e-modifier-is-deprecated-use-preg_replace_callback-instead

    我复制了新的core/Security.php 并粘贴到我的上面,它现在可以工作了。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-17
    • 2021-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多