如何在 codeigniter 中获得 $_POST 完整值而不对其进行任何清理操作?

发布于 2024-12-25 05:09:36 字数 720 浏览 1 评论 0原文

我在 codeigniter 中有一个类似这样的控制器:

class ABC extends MX_Controller {
  ...
  ...
  ...
   .
   .
   .
  ...
  ...

  public function getTestPostData(){
    print_r($_POST);
  }
}

getTestPostData 中,当我打印 $_POST 时,我需要完整的 $_POST 数据,而不进行任何类型的清理。我无法在 config.php 中设置 $config['global_xss_filtering'] = FALSE;

我该如何实现?

编辑:

在发布数据中,我发送一些带有一些

我希望现在问题已经清楚了。

I have a controller something like this in codeigniter:

class ABC extends MX_Controller {
  ...
  ...
  ...
   .
   .
   .
  ...
  ...

  public function getTestPostData(){
    print_r($_POST);
  }
}

In getTestPostData when i print $_POST i need full $_POST data without any sanitization of any kind. I can't set $config['global_xss_filtering'] = FALSE; in config.php

How can i achieve that?

Edit:

In post data i am sending some HTML content with some <script>(script) tags, but when i print the data in my controller using $this->input->post("content") the <script>(script)tags gets replace by [removed] tags. This happens when the global_xss_filtering is TRUE. I can't change this value to FALSE.

I hope now the question is clear.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

森林很绿却致人迷途 2025-01-01 05:09:36

试试这个,在我的测试中,即使在完全取消 $_POST 后它仍然有效。

public function getTestPostData()
{
    $post_data = explode( "&", file_get_contents('php://input') );
    $result = array();

    foreach( $post_data as $post_datum ) {
        $pair = explode("=", $post_datum );

        $result[urldecode($pair[0])] = urldecode($pair[1]);
    }

    print_r( $result );
}

Try this, in my tests it worked even after unsetting $_POST completely.

public function getTestPostData()
{
    $post_data = explode( "&", file_get_contents('php://input') );
    $result = array();

    foreach( $post_data as $post_datum ) {
        $pair = explode("=", $post_datum );

        $result[urldecode($pair[0])] = urldecode($pair[1]);
    }

    print_r( $result );
}
≈。彩虹 2025-01-01 05:09:36

你不能设置 $config['global_xss_filtering'] = FALSE;在 config.php 中?

那么如果你无法访问 core/input.php 类
并从中删除 _POST

function _sanitize_globals()
{
    // It would be "wrong" to unset any of these GLOBALS.
    $protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', 
                        '_SESSION', '_ENV', 'GLOBALS', 

或将 var $xss_clean 更改为 false ,

    function get_post($index = '', $xss_clean = FALSE)
{
    if ( ! isset($_POST[$index]) )
    {
        return $this->get($index, false); //here
    }

这样您就无法查看未过滤的帖子

 print_r($_POST);
print_r( $this->input->post() )

数据

you can't set $config['global_xss_filtering'] = FALSE; in config.php?

then if you can't access core/input.php class
and remove _POST from it

function _sanitize_globals()
{
    // It would be "wrong" to unset any of these GLOBALS.
    $protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', 
                        '_SESSION', '_ENV', 'GLOBALS', 

or change the var $xss_clean to false like this

    function get_post($index = '', $xss_clean = FALSE)
{
    if ( ! isset($_POST[$index]) )
    {
        return $this->get($index, false); //here
    }

then you can't view the post data unfiltered from

 print_r($_POST);
print_r( $this->input->post() )

that's all

披肩女神 2025-01-01 05:09:36

如果您有 CI v. 2+,请尝试以下操作:

创建一个扩展 CI_Security 的新核心文件并覆盖 xss_clean 函数,如下所示:

class MY_Security extends CI_Security {

    public function xss_clean($str, $is_image = FALSE)
    {
      return $str;
    }
}

编辑: 我刚刚测试了这个,它作品。供参考。

If you have CI v. 2+ try the following:

Create a new Core file that extends CI_Security and overwrite the xss_clean function like so:

class MY_Security extends CI_Security {

    public function xss_clean($str, $is_image = FALSE)
    {
      return $str;
    }
}

EDIT: I just tested this and it works. FYI.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文