Improved strip method for performance and clarity.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7866 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
TommyO 2008-11-11 19:54:15 +00:00
parent 5f0858e1ad
commit 11f0817341

View file

@ -623,32 +623,15 @@ class EmailComponent extends Object{
* @access private
*/
function __strip($value, $message = false) {
/*
$search = '%0a|%0d|Content-(?:Type|Transfer-Encoding)\:|charset\=|mime-version\:|multipart/mixed|(?:to|b?cc)\:.*';
if ($message !== true) {
$search .= '|\\r|\\n';
$search .= '|\r|\n';
}
$search = '#(?:' . $search . ')#i';
while (preg_match($search, $value)) {
$value = preg_replace($search, '', $value);
}
return $value;
*/
$search = array(
'/(?:%0a)/i', '/(?:%0d)/i', '/(?:Content-Type\:)/i', '/(?:charset\=)/i', '/(?:mime-version\:)/i',
'/(?:multipart\/mixed)/i', '/(?:bcc\:.*)/i','/(?:to\:.*)/i','/(?:cc\:.*)/i', '/(?:Content-Transfer-Encoding\:)/i',
'/\\r/i', '/\\n/i'
);
if ($message === true) {
$search = array_slice($search, 0, -2);
}
foreach ($search as $key) {
while (preg_match($key, $value)) {
$value = preg_replace($key, '', $value);
}
}
return preg_replace($search, '', $value);
}
/**
* Wrapper for PHP mail function used for sending out emails