Skip to content

Commit

Permalink
MAGETWO-34955: [GITHUB]Email message containing non English character…
Browse files Browse the repository at this point in the history
… is displayed incorrectly on the receiver. #1086

fixed encoding and template processing
  • Loading branch information
Serhiy Shkolyarenko committed Mar 16, 2015
1 parent 0c03986 commit 8883d36
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/code/Magento/Email/Model/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,16 @@ public function loadDefault($templateId)
$modulesDirectory = $this->_filesystem->getDirectoryRead(DirectoryList::MODULES);
$templateText = $modulesDirectory->readFile($modulesDirectory->getRelativePath($templateFile));

/**
* trim copyright message for text templates
*/
if ('html' != $templateType
&& preg_match('/^<!--[\w\W]+?-->/m', $templateText, $matches)
&& strpos($matches[0], 'Copyright') > 0
) {
$templateText = str_replace($matches[0], '', $templateText);
}

if (preg_match('/<!--@subject\s*(.*?)\s*@-->/u', $templateText, $matches)) {
$this->setTemplateSubject($matches[1]);
$templateText = str_replace($matches[0], '', $templateText);
Expand All @@ -335,9 +345,9 @@ public function loadDefault($templateId)
}

/**
* Remove comment lines
* Remove comment lines and extra spaces
*/
$templateText = preg_replace('#\{\*.*\*\}#suU', '', $templateText);
$templateText = trim(preg_replace('#\{\*.*\*\}#suU', '', $templateText));

$this->setTemplateText($templateText);
$this->setId($templateId);
Expand Down
8 changes: 8 additions & 0 deletions lib/internal/Magento/Framework/Mail/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@

class Message extends \Zend_Mail implements MessageInterface
{
/**
* @param string $charset
*/
public function __construct($charset = 'utf-8')
{
parent::__construct($charset);
}

/**
* Message type
*
Expand Down

0 comments on commit 8883d36

Please sign in to comment.