Skip to content

Commit 884e55e

Browse files
committed
AC-10269: Gift registry frontend enhancements
* Code refinements
1 parent 5d53fda commit 884e55e

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

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

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Laminas\Mail\AddressList;
1515
use Laminas\Mime\Message as LaminasMimeMessage;
1616
use Psr\Log\LoggerInterface;
17-
use Laminas\Validator\EmailAddress as LaminasEmailAddress;
1817

1918
/**
2019
* Magento Framework Email message
@@ -28,11 +27,7 @@ class EmailMessage extends Message implements EmailMessageInterface
2827
*/
2928
private const ARRAY_RCE_CHARACTERS = [
3029
',',
31-
';',
32-
'<',
33-
'>',
34-
'&lt',
35-
'&gt'
30+
';'
3631
];
3732

3833
/**
@@ -50,11 +45,6 @@ class EmailMessage extends Message implements EmailMessageInterface
5045
*/
5146
private $logger;
5247

53-
/**
54-
* @var LaminasEmailAddress|null
55-
*/
56-
private $emailValidator;
57-
5848
/**
5949
* @param MimeMessageInterface $body
6050
* @param array $to
@@ -68,7 +58,6 @@ class EmailMessage extends Message implements EmailMessageInterface
6858
* @param string|null $subject
6959
* @param string|null $encoding
7060
* @param LoggerInterface|null $logger
71-
* @param LaminasEmailAddress|null $emailValidator
7261
* @throws InvalidArgumentException
7362
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
7463
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -86,13 +75,11 @@ public function __construct(
8675
?Address $sender = null,
8776
?string $subject = '',
8877
?string $encoding = 'utf-8',
89-
?LoggerInterface $logger = null,
90-
?LaminasEmailAddress $emailValidator = null
78+
?LoggerInterface $logger = null
9179
) {
9280
parent::__construct($encoding);
9381
$mimeMessage = new LaminasMimeMessage();
9482
$this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class);
95-
$this->emailValidator = $emailValidator ?: ObjectManager::getInstance()->get(LaminasEmailAddress::class);
9683
$mimeMessage->setParts($body->getParts());
9784
$this->zendMessage->setBody($mimeMessage);
9885
if ($subject) {
@@ -289,17 +276,10 @@ private function convertAddressArrayToAddressList(array $arrayList): AddressList
289276
*/
290277
private function sanitiseEmail(?string $email): ?string
291278
{
292-
if (isset($email) && str_contains($email, '=??')) {
293-
$decodedValue = iconv_mime_decode($email, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8');
294-
if (
295-
$this->isEncoded(trim($email), trim($decodedValue)) &&
296-
!$this->emailValidator->isValid((trim($decodedValue)))
297-
) {
298-
$email = trim(str_replace(
299-
'/',
300-
'',
301-
$decodedValue
302-
));
279+
if (!empty($email) && str_contains($email, '=?')) {
280+
$decodedValue = trim(iconv_mime_decode($email, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'));
281+
if ($this->isEncoded(trim($email), $decodedValue)) {
282+
$email = strtolower($decodedValue);
303283
}
304284
}
305285

@@ -314,7 +294,7 @@ private function sanitiseEmail(?string $email): ?string
314294
*/
315295
private function sanitiseName(?string $name): ?string
316296
{
317-
if (isset($name)) {
297+
if (!empty($name)) {
318298
return trim(str_replace(
319299
self::ARRAY_RCE_CHARACTERS,
320300
'',
@@ -326,7 +306,7 @@ private function sanitiseName(?string $name): ?string
326306
}
327307

328308
/**
329-
* Check email is decoded
309+
* Check email is encoded
330310
*
331311
* @param string $originalEmail
332312
* @param string $decodedEmail

0 commit comments

Comments
 (0)