mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 15:06:06 +00:00
email body plain fix
This commit is contained in:
@@ -84,7 +84,33 @@ class Email extends \Espo\Core\ORM\Entity
|
||||
$breaks = array("<br />","<br>","<br/>","<br />","<br />","<br/>","<br>");
|
||||
$body = str_ireplace($breaks, "\r\n", $body);
|
||||
$body = strip_tags($body);
|
||||
$body = str_ireplace(' ', ' ', $body);
|
||||
|
||||
$reList = [
|
||||
'/&(quot|#34);/i',
|
||||
'/&(amp|#38);/i',
|
||||
'/&(lt|#60);/i',
|
||||
'/&(gt|#62);/i',
|
||||
'/&(nbsp|#160);/i',
|
||||
'/&(iexcl|#161);/i',
|
||||
'/&(cent|#162);/i',
|
||||
'/&(pound|#163);/i',
|
||||
'/&(copy|#169);/i',
|
||||
'/&(reg|#174);/i'
|
||||
];
|
||||
$replaceList = [
|
||||
'',
|
||||
'&',
|
||||
'<',
|
||||
'>',
|
||||
' ',
|
||||
chr(161),
|
||||
chr(162),
|
||||
chr(163),
|
||||
chr(169),
|
||||
chr(174)
|
||||
];
|
||||
|
||||
$body = preg_replace($reList, $replaceList, $body);
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
@@ -467,8 +467,8 @@ class EmailTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
function testBodyPlain()
|
||||
{
|
||||
$this->email->set('body', '<br /> ');
|
||||
$this->email->set('body', '<br /> &');
|
||||
$bodyPlain = $this->email->getBodyPlain();
|
||||
$this->assertEquals($bodyPlain, "\r\n ");
|
||||
$this->assertEquals($bodyPlain, "\r\n &");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user