43
protectmail
protect_mail
SYNOPSIS
protect_mail($s)
DESCRIPTION
protect_mail returns the string $s without the characters and escape sequences that may be used for email header injection.
EXAMPLE
php > require 'library/protectmail.php';
php > $addr="user@example.com\r\nBcc: hacker@example.com";
php > var_dump(protect_mail($addr));
string(39) "user@example.comBcc: hacker@example.com"
CODE
- function protect_mail($s) {
- return preg_replace('/[\r\n\t]|%0a|%0d|%08|%09/i', '', $s);
- }
Comments