10 defined(
'JPATH_PLATFORM') or die;
33 public static function cleanLine($value)
37 return trim(preg_replace(
'/(%0A|%0D|\n+|\r+)/i',
'', $value));
49 public static function cleanText($value)
51 return trim(preg_replace(
'/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i',
'', $value));
63 public static function cleanBody($body)
66 return preg_replace(
"/((From:|To:|Cc:|Bcc:|Subject:|Content-type:) ([\S]+))/",
"", $body);
78 public static function cleanSubject($subject)
80 return preg_replace(
"/((From:|To:|Cc:|Bcc:|Content-type:) ([\S]+))/",
"", $subject);
92 public static function cleanAddress($address)
94 if (preg_match(
"[\s;,]", $address))
111 public static function isEmailAddress($email)
114 $atIndex = strrpos($email,
"@");
115 $domain = substr($email, $atIndex + 1);
116 $local = substr($email, 0, $atIndex);
119 $domainLen = strlen($domain);
121 if ($domainLen < 1 || $domainLen > 255)
131 $allowed =
'A-Za-z0-9!#&*+=?_-';
132 $regex =
"/^[$allowed][\.$allowed]{0,63}$/";
134 if (!preg_match($regex, $local) || substr($local, -1) ==
'.')
140 $regex =
'/^[0-9\.]+$/';
142 if (preg_match($regex, $domain))
148 $localLen = strlen($local);
150 if ($localLen < 1 || $localLen > 64)
156 $domain_array = explode(
".", rtrim($domain,
'.'));
157 $regex =
'/^[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/';
159 foreach ($domain_array as $domain)
171 if (!preg_match($regex, $domain))
177 if (strpos($domain,
'-') === 0)
183 $length = strlen($domain) - 1;
185 if (strpos($domain,
'-', $length) === $length)