[英]Cleaning user input before sending it in mail
I am using PHPMailer class to send mails. 我正在使用PHPMailer类发送邮件。 Some mails contain user input. 有些邮件包含用户输入。 Should I clean user input before inserting it to mail body
? 在将用户输入插入mail body
之前,是否应该清除用户输入? How to do this? 这个怎么做?
Tried to google for it but haven't fount anything useful. 试图谷歌,但没有发现任何有用的东西。
是的,您应该ALWAYS
清理/清除用户输入,以防止代码或SQL注入。
Sanitation is always key when handling user input. 处理用户输入时,卫生始终是关键。
strip_tags
to limit the HTML tags they're allowed to use, if any. 您可以使用strip_tags
限制允许使用的HTML标签(如果有)。 htmlspecialchars
will properly change things like <
into <
htmlspecialchars
可以正确地将<
等更改为<
so they can't be evaluated as HTML. 因此无法将它们评估为HTML。 pg_escape_string
PostgreSQL- pg_escape_string
mysql_real_escape_string
MySQL- mysql_real_escape_string
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.