FILTER_VALIDATE_EMAIL是否使字符串安全插入数据库? [英] Does FILTER_VALIDATE_EMAIL make a string safe for insertion in database?

查看:130
本文介绍了FILTER_VALIDATE_EMAIL是否使字符串安全插入数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $ str ='mynam @ blabl@ domanin.com'; 

filter_var($ str,FILTER_VALIDATE_EMAIL); //返回有效的电子邮件。

上述电子邮件返回true ...公平的RFC 2822说这是一个合法的电子邮件地址。 / p>

我的问题是,如果您使用上述验证电子邮件,电子邮件是否携带sql注入,即使您已使用filter_var过滤数据库,也可能会损坏数据库?

解决方案


我的问题是,如果您使用上述验证电子邮件,则电子邮件携带可能会损坏数据库的sql注入虽然你已经过滤了filter_var?


filter_var 替换数据库特定的卫生设备,如 mysql_real_escape_string()!一个人也需要总是适用。


$str = '"mynam@blabl"@domanin.com';

filter_var($str, FILTER_VALIDATE_EMAIL);//return valid email.

the above email returns true... Fair enough that RFC 2822 says it's a legal email address.

my question is if you validate an email using the above could an email carry sql injections that can harm the db even though you have filtered it with filter_var?

解决方案

my question is if you validate an email using the above could an email carry sql injections that can harm the db even though you have filtered it with filter_var?

filter_var is not a replacement for database specific sanitation like mysql_real_escape_string()! One needs to always apply that, too.

这篇关于FILTER_VALIDATE_EMAIL是否使字符串安全插入数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆