mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
parent
c9c3983296
commit
9eeecc8755
2 changed files with 20 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in a new issue