Skip to content

Commit 8883d36

Browse files
author
Serhiy Shkolyarenko
committed
MAGETWO-34955: [GITHUB]Email message containing non English character is displayed incorrectly on the receiver. #1086
fixed encoding and template processing
1 parent 0c03986 commit 8883d36

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

app/code/Magento/Email/Model/Template.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,16 @@ public function loadDefault($templateId)
319319
$modulesDirectory = $this->_filesystem->getDirectoryRead(DirectoryList::MODULES);
320320
$templateText = $modulesDirectory->readFile($modulesDirectory->getRelativePath($templateFile));
321321

322+
/**
323+
* trim copyright message for text templates
324+
*/
325+
if ('html' != $templateType
326+
&& preg_match('/^<!--[\w\W]+?-->/m', $templateText, $matches)
327+
&& strpos($matches[0], 'Copyright') > 0
328+
) {
329+
$templateText = str_replace($matches[0], '', $templateText);
330+
}
331+
322332
if (preg_match('/<!--@subject\s*(.*?)\s*@-->/u', $templateText, $matches)) {
323333
$this->setTemplateSubject($matches[1]);
324334
$templateText = str_replace($matches[0], '', $templateText);
@@ -335,9 +345,9 @@ public function loadDefault($templateId)
335345
}
336346

337347
/**
338-
* Remove comment lines
348+
* Remove comment lines and extra spaces
339349
*/
340-
$templateText = preg_replace('#\{\*.*\*\}#suU', '', $templateText);
350+
$templateText = trim(preg_replace('#\{\*.*\*\}#suU', '', $templateText));
341351

342352
$this->setTemplateText($templateText);
343353
$this->setId($templateId);

lib/internal/Magento/Framework/Mail/Message.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99

1010
class Message extends \Zend_Mail implements MessageInterface
1111
{
12+
/**
13+
* @param string $charset
14+
*/
15+
public function __construct($charset = 'utf-8')
16+
{
17+
parent::__construct($charset);
18+
}
19+
1220
/**
1321
* Message type
1422
*

0 commit comments

Comments
 (0)