POST中存在非法字符.可能的电子邮件注入尝试错误


Illegal characters in POST. Possible email injection attempt error

正在与此作斗争。

我已经使用Wordpress为客户设置了一个基本的电子邮件/询问表(快速安全联系表-Mike Challis,我以前使用过,没有问题)。

我用各种电子邮件测试了它-让其他人测试-都很好。

传递给客户以供批准,他的电子邮件地址(其中两个)创建了错误:POST中的非法字符。可能的电子邮件注入尝试

一个是BT电子邮件,另一个是Gmail。我再次测试了BT和Gmail,对我的地址来说都很好——我再次尝试了他的测试,但出现了同样的错误。

我在测试时确实对帐户密码进行了保护,所以我禁用了帐户密码,看看这是否是问题所在,但没有什么区别。

有相当多的代码,所以我还不会粘贴它,因为我马上就知道为什么会这样。

我最初的表单有一些自定义(仅视觉),但即使是在最简单的插件新安装时,也会出现同样的错误——只有客户端的电子邮件地址。令人尴尬的

我真的很感激你的预感。

感谢

我在插件中找到了这段代码(最新wordpress插件版本中的1433行及以后):

// check posted input for email injection attempts
// Check for these common exploits
// if you edit any of these do not break the syntax of the regex
$input_expl = "/(content-type|mime-version|content-transfer-encoding|to:|bcc:|cc:|document.cookie|document.write|onmouse|onkey|onclick|onload)/i";
// Loop through each POST'ed value and test if it contains one of the exploits fromn $input_expl:
foreach($_POST as $k => $v){
    if (is_string($v)){
        $v = strtolower($v);
        $v = str_replace('donkey','',$v); // fixes invalid input with "donkey" in string
        $v = str_replace('monkey','',$v); // fixes invalid input with "monkey" in string
        if( preg_match($input_expl, $v) ){
            return __('Illegal characters in POST. Possible email injection attempt', 'si-contact-form');
        }
    }
}

当至少有一个已发布的字段在字符串中的任何位置包含"无效"值时,就会发生错误。在电子邮件地址上触发此错误的最有可能的候选者似乎是onhouse、onkey、onclick和onload。(请注意,单词"驴"answers"猴子"是允许的。)您应该在return语句之前检查$v的值,以便确定导致错误的部分,然后再决定如何解决问题。

        if( preg_match($input_expl, $v) ){
            var_dump($v); exit(); // <-- add this for testing
            return __('Illegal characters in POST. Possible email injection attempt', 'si-contact-form');
        }