Adding content stripping fix for email component, fixes #4753

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7043 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-05-25 18:08:55 +00:00
parent c9c3983296
commit 9eeecc8755
2 changed files with 20 additions and 3 deletions

View file

@ -620,13 +620,21 @@ class EmailComponent extends Object{
* @access private
*/
function __strip($value, $message = false) {
$search = array('/%0a/i', '/%0d/i', '/Content-Type\:/i',
'/charset\=/i', '/mime-version\:/i', '/multipart\/mixed/i',
'/bcc\:.*/i','/to\:.*/i','/cc\:.*/i', '/\\r/i', '/\\n/i');
$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);
}
/**

View file

@ -164,6 +164,15 @@ TEMPDOC;
$this->assertTrue($this->Controller->Email->send('This is the body of the message'));
}
}
function testContentStripping() {
$content = "Previous content\n--alt-\nContent-TypeContent-Type:: text/html; charsetcharset==utf-8\nContent-Transfer-Encoding: 7bit";
$content .= "\n\n<p>My own html content</p>";
$result = $this->Controller->Email->__strip($content, true);
$expected = "Previous content\n--alt-\n text/html; utf-8\n 7bit\n\n<p>My own html content</p>";
$this->assertEqual($result, $expected);
}
}
?>