Skip to content

Commit d63b04e

Browse files
committed
https://github.com/magento-cia/magento2ce/pull/629
* Exception updated
1 parent f95e264 commit d63b04e

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
use Laminas\Mail\Exception\InvalidArgumentException as LaminasInvalidArgumentException;
1111
use Magento\Framework\App\ObjectManager;
12-
use Magento\Framework\Exception\LocalizedException;
1312
use Magento\Framework\Mail\Exception\InvalidArgumentException;
1413
use Laminas\Mail\Address as LaminasAddress;
1514
use Laminas\Mail\AddressList;
@@ -52,7 +51,6 @@ class EmailMessage extends Message implements EmailMessageInterface
5251
* @param string|null $encoding
5352
* @param LoggerInterface|null $logger
5453
* @throws InvalidArgumentException
55-
* @throws LocalizedException
5654
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
5755
* @SuppressWarnings(PHPMD.NPathComplexity)
5856
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -126,7 +124,7 @@ public function getHeaders(): array
126124
/**
127125
* @inheritDoc
128126
*
129-
* @throws LocalizedException
127+
* @throws InvalidArgumentException
130128
*/
131129
public function getFrom(): ?array
132130
{
@@ -136,7 +134,7 @@ public function getFrom(): ?array
136134
/**
137135
* @inheritDoc
138136
*
139-
* @throws LocalizedException
137+
* @throws InvalidArgumentException
140138
*/
141139
public function getTo(): array
142140
{
@@ -146,7 +144,7 @@ public function getTo(): array
146144
/**
147145
* @inheritDoc
148146
*
149-
* @throws LocalizedException
147+
* @throws InvalidArgumentException
150148
*/
151149
public function getCc(): ?array
152150
{
@@ -156,7 +154,7 @@ public function getCc(): ?array
156154
/**
157155
* @inheritDoc
158156
*
159-
* @throws LocalizedException
157+
* @throws InvalidArgumentException
160158
*/
161159
public function getBcc(): ?array
162160
{
@@ -166,7 +164,7 @@ public function getBcc(): ?array
166164
/**
167165
* @inheritDoc
168166
*
169-
* @throws LocalizedException
167+
* @throws InvalidArgumentException
170168
*/
171169
public function getReplyTo(): ?array
172170
{
@@ -222,7 +220,7 @@ public function toString(): string
222220
*
223221
* @param AddressList $addressList
224222
* @return Address[]
225-
* @throws LocalizedException
223+
* @throws InvalidArgumentException
226224
*/
227225
private function convertAddressListToAddressArray(AddressList $addressList): array
228226
{
@@ -245,7 +243,7 @@ private function convertAddressListToAddressArray(AddressList $addressList): arr
245243
*
246244
* @param Address[] $arrayList
247245
* @return AddressList
248-
* @throws LaminasInvalidArgumentException|LocalizedException
246+
* @throws LaminasInvalidArgumentException|InvalidArgumentException
249247
*/
250248
private function convertAddressArrayToAddressList(array $arrayList): AddressList
251249
{
@@ -273,15 +271,14 @@ private function convertAddressArrayToAddressList(array $arrayList): AddressList
273271
*
274272
* @param ?string $email
275273
* @return ?string
276-
* @throws LocalizedException
274+
* @throws InvalidArgumentException
277275
*/
278276
private function sanitiseEmail(?string $email): ?string
279277
{
280278
if (!empty($email) && str_starts_with($email, '=?')) {
281279
$decodedValue = iconv_mime_decode($email, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8');
282-
$localPart = explode('@', $decodedValue);
283-
if (isset($localPart[0]) && str_contains($localPart[0], ' ')) {
284-
throw new LocalizedException(__('Invalid email format'));
280+
if (str_contains($decodedValue, ' ')) {
281+
throw new InvalidArgumentException('Invalid email format');
285282
}
286283
}
287284

0 commit comments

Comments
 (0)