zoukankan      html  css  js  c++  java
  • Debugging Tip: “Disallowed Key Character” Error In CodeIgniter

    关于这个错误。看到有人直接修改了 Input.php 。觉得不妥,查阅了一下,一个令我满意的答案是

    After 6 hours of massive anxiety, stress, near tears, one pound on my desk, and some hair pulling, I tracked down the source of a nagging Disallowed Key Character error that I received while using CodeIgniter: an extra line break.

    The line feed (LF) and carriage return (CR) characters (and their hex code equivalents (%0D and %0A) are forbidden in CodeIgniter’s framework. The hard part is tracking down exactly where that extra line break character lives.

    In my case, there was an extra line of blank, barren, not-all-that-obvious white space at the very, very end of one of my controller files, just after the closing ?>.

     

    所以这是一个编程习惯的问题,so,

    delete *anything* after the closing ?> -- including white space and line breaks -- or remove the ?>.

    如果你想搞清楚哪个字符的问题,可以尝试这样

    In the core CI code in system/libraries is a file called input.php I made a small modification to that file so that it would show the actual data in question.

    Around line number 199

    function _clean_input_keys($str)
    {
    if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
    {
    exit('Disallowed Key Characters: '.$str); // Added the variable to display.
    }

    return $str;
    }

    另外一种情况,disallowed characters in a POST array

    In my case, I had single-quotes as part of the variable name. My fingers mixed up PHP array syntax and HTML form syntax.

    <!-- will cause the error -->
    <input type="text" name="fieldname['foo']" value=""> 
    
    <!-- won't cause the error. besides, this is the proper syntax. -->
    <input type="text" name="fieldname[foo]" value="">
    

    kalodont points out this can also happen when using accented characters, such as ó or ñ as keys in your array.

  • 相关阅读:
    JZOJ 2020.10.6 提高B组反思
    【NOIP2011模拟11.1】钓鱼
    JZOJ【NOIP2012模拟8.9】2020.10.5 T1
    ⑫linux基础命令 过滤 grep
    ⑪linux基础命令 tail
    ⑩linux基础命令 head
    ⑨linux基础命令 cat
    ⑧linux基础命令 rm
    ⑦linux基础命令 mv
    ⑥linux基础命令 cp
  • 原文地址:https://www.cnblogs.com/leonbond/p/2550919.html
Copyright © 2011-2022 走看看