14
14
use Laminas \Mail \AddressList ;
15
15
use Laminas \Mime \Message as LaminasMimeMessage ;
16
16
use Psr \Log \LoggerInterface ;
17
- use Laminas \Validator \EmailAddress as LaminasEmailAddress ;
18
17
19
18
/**
20
19
* Magento Framework Email message
@@ -28,11 +27,7 @@ class EmailMessage extends Message implements EmailMessageInterface
28
27
*/
29
28
private const ARRAY_RCE_CHARACTERS = [
30
29
', ' ,
31
- '; ' ,
32
- '< ' ,
33
- '> ' ,
34
- '< ' ,
35
- '> '
30
+ '; '
36
31
];
37
32
38
33
/**
@@ -50,11 +45,6 @@ class EmailMessage extends Message implements EmailMessageInterface
50
45
*/
51
46
private $ logger ;
52
47
53
- /**
54
- * @var LaminasEmailAddress|null
55
- */
56
- private $ emailValidator ;
57
-
58
48
/**
59
49
* @param MimeMessageInterface $body
60
50
* @param array $to
@@ -68,7 +58,6 @@ class EmailMessage extends Message implements EmailMessageInterface
68
58
* @param string|null $subject
69
59
* @param string|null $encoding
70
60
* @param LoggerInterface|null $logger
71
- * @param LaminasEmailAddress|null $emailValidator
72
61
* @throws InvalidArgumentException
73
62
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
74
63
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -86,13 +75,11 @@ public function __construct(
86
75
?Address $ sender = null ,
87
76
?string $ subject = '' ,
88
77
?string $ encoding = 'utf-8 ' ,
89
- ?LoggerInterface $ logger = null ,
90
- ?LaminasEmailAddress $ emailValidator = null
78
+ ?LoggerInterface $ logger = null
91
79
) {
92
80
parent ::__construct ($ encoding );
93
81
$ mimeMessage = new LaminasMimeMessage ();
94
82
$ this ->logger = $ logger ?: ObjectManager::getInstance ()->get (LoggerInterface::class);
95
- $ this ->emailValidator = $ emailValidator ?: ObjectManager::getInstance ()->get (LaminasEmailAddress::class);
96
83
$ mimeMessage ->setParts ($ body ->getParts ());
97
84
$ this ->zendMessage ->setBody ($ mimeMessage );
98
85
if ($ subject ) {
@@ -289,17 +276,10 @@ private function convertAddressArrayToAddressList(array $arrayList): AddressList
289
276
*/
290
277
private function sanitiseEmail (?string $ email ): ?string
291
278
{
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 );
303
283
}
304
284
}
305
285
@@ -314,7 +294,7 @@ private function sanitiseEmail(?string $email): ?string
314
294
*/
315
295
private function sanitiseName (?string $ name ): ?string
316
296
{
317
- if (isset ($ name )) {
297
+ if (! empty ($ name )) {
318
298
return trim (str_replace (
319
299
self ::ARRAY_RCE_CHARACTERS ,
320
300
'' ,
@@ -326,7 +306,7 @@ private function sanitiseName(?string $name): ?string
326
306
}
327
307
328
308
/**
329
- * Check email is decoded
309
+ * Check email is encoded
330
310
*
331
311
* @param string $originalEmail
332
312
* @param string $decodedEmail
0 commit comments