首页 > 其他 > 详细

雷林鹏分享:解决CI框架的Disallowed Key Characters错误提示

时间:2019-05-22 14:11:28      阅读:112      评论:0      收藏:0      [点我收藏+]

  用CI框架时,有时候会遇到这么一个问题,打开网页,只显示 Disallowed Key Characters 错误提示。有人说 url 里有非法字符。但是确定 url 是纯英文的,问题还是出来了。但清空浏览器历史记录和cookies后。 刷新就没问题了。有时候。打开不同的浏览器。有的浏览器会有问题。有的就不会。

  解决 CodeIgniter 框架应用中,出现Disallowed Key Characters错误提示的方法。找到core文件夹下的Input文件,将下面的代码:

  function _clean_input_keys($str)

  {

  if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))

  {

  exit(‘Disallowed Key Characters.‘);

  }

  // Clean UTF-8 if supported

  if (UTF8_ENABLED === TRUE)

  {

  $str = $this->uni->clean_string($str);

  }

  return $str;

  }

  解决方法:

  方法一:

  function _clean_input_keys($str)

  {

  $config = &get_config(‘config‘);

  if ( ! preg_match("/^[".$config[‘permitted_uri_chars‘]."]+$/i", rawurlencode($str)))

  {

  exit(‘Disallowed Key Characters.‘);

  }

  // Clean UTF-8 if supported

  if (UTF8_ENABLED === TRUE)

  {

  $str = $this->uni->clean_string($str);

  }

  return $str;

  }

  方法二:

  function _clean_input_keys($str)

  {

  if(preg_match("/^,_[a-z0-9:_\/-]+$/",$str)){

  $str = preg_replace("/,_/","",$str);

  }

  if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))

  {

  exit(‘Disallowed Key Characters.‘.$str);

  }

  return $str;

  }

  文章转载自 [http://www.php230.com]

  (编辑:雷林鹏 来源:网络 侵删)

雷林鹏分享:解决CI框架的Disallowed Key Characters错误提示

原文:https://www.cnblogs.com/linpeng1/p/10905480.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!