不允许的关键字符

时间:2014-01-28 10:57:37

标签: php codeigniter preg-match

我遇到了CI禁止关键字符的问题。当我更改核心文件input.php

exit('Disallowed Key Characters!! Clear Your Cookies.'.$str);

我得到这个字符串

Disallowed Key Characters!!.qqfilechunk|attraction-Pulaki-temple-not-far-from-Jimbaran-seminyak-kuta-leagian-nusa-dua-and-sanur-close-to-cheap-hotels-cheap-flight-with-air-asia-4-can-be-great-experience-to-come-to-bali-and-enj-_jpg|101077|2000000

我已将pregmatch更改为

preg_match("/^[#a-z0-9:_\/-|{}()%!=]+$/i", $str)

但我仍然收到Disallowed Key Character消息。

2 个答案:

答案 0 :(得分:1)

你的正则表达式存在一些问题:

  • - 必须转到字符块的末尾,因为这通常表示一系列字符
  • 您的测试字符串不匹配的原因是因为您不允许使用.句号。

将正则表达式更改为:

/^[#a-z0-9:_\/|{}()%!=.-]+$/i

可以使用RegexPal测试页here

答案 1 :(得分:0)

将其更改为:

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

它将避免错误。

检查您的输入标签是否还有任何缺失的引号或其他内容:

在这种情况下会发生错误:

<input type="text" name="nam value=" " />

因为我错过了名称标签的收尾报价!

检查这些类型的错误....

相关问题