Source for file helper.php
Documentation is available at helper.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Email helper class, provides static methods to perform various tasks relevant
* to the Joomla email routines.
* TODO: Test these methods as the regex work is first run and not tested thoroughly
* @package Joomla.Platform
* Cleans single line inputs.
* @param string $value String to be cleaned.
* @return string Cleaned string.
* Cleans multi-line inputs.
* @param string $value Multi-line string to be cleaned.
* @return string Cleaned multi-line string.
return trim(preg_replace('/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i', '', $value));
* Cleans any injected headers from the email body.
* @param string $body email body string.
* @return string Cleaned email body string.
// Strip all email headers from a string
return preg_replace("/((From:|To:|Cc:|Bcc:|Subject:|Content-type:) ([\S]+))/", "", $body);
* Cleans any injected headers from the subject string.
* @param string $subject email subject string.
* @return string Cleaned email subject string.
return preg_replace("/((From:|To:|Cc:|Bcc:|Content-type:) ([\S]+))/", "", $subject);
* Verifies that an email address does not have any extra headers injected into it.
* @param string $address email address.
* @return mixed email address string or boolean false if injected headers are present.
* Verifies that the string is in a proper email address format.
* @param string $email String to be verified.
* @return boolean True if string has the correct format; false otherwise.
// Split the email into a local and domain
$domain =
substr($email, $atIndex +
1);
$local =
substr($email, 0, $atIndex);
// Check Length of domain
if ($domainLen <
1 ||
$domainLen >
255)
* Check the local address
* We're a bit more conservative about what constitutes a "legal" address, that is, A-Za-z0-9!#$%&\'*+/=?^_`{|}~-
* Also, the last character in local cannot be a period ('.')
$allowed =
'A-Za-z0-9!#&*+=?_-';
$regex =
"/^[$allowed][\.$allowed]{0,63}$/";
// No problem if the domain looks like an IP address, ish
if ($localLen <
1 ||
$localLen >
64)
$regex =
'/^[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/';
foreach ($domain_array as $domain)
// Convert domain to punycode
// Check for invalid characters
// Check for a dash at the beginning of the domain
if (strpos($domain, '-') ===
0)
// Check for a dash at the end of the domain
$length =
strlen($domain) -
1;
if (strpos($domain, '-', $length) ===
$length)
Documentation generated on Tue, 19 Nov 2013 15:04:22 +0100 by phpDocumentor 1.4.3