Skip to content

Commit dc5a14e

Browse files
MAGETWO-64901: Bypassing outdated TLD validation
1 parent 1e19c93 commit dc5a14e

File tree

13 files changed

+144
-23
lines changed

13 files changed

+144
-23
lines changed

app/code/Magento/Config/Model/Config/Backend/Email/Address.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Address extends \Magento\Framework\App\Config\Value
2323
public function beforeSave()
2424
{
2525
$value = $this->getValue();
26-
if (!\Zend_Validate::is($value, 'EmailAddress')) {
26+
if (!\Zend_Validate::is($value, \Magento\Framework\Validator\EmailAddress::class)) {
2727
throw new LocalizedException(__('Please correct the email address: "%1".', $value));
2828
}
2929
return $this;

app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function execute()
6060
$resultRedirect = $this->resultRedirectFactory->create();
6161
$email = (string)$this->getRequest()->getPost('email');
6262
if ($email) {
63-
if (!\Zend_Validate::is($email, 'EmailAddress')) {
63+
if (!\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) {
6464
$this->session->setForgottenEmail($email);
6565
$this->messageManager->addErrorMessage(__('Please correct the email address.'));
6666
return $resultRedirect->setPath('*/*/forgotpassword');

app/code/Magento/Customer/Model/Metadata/Form/AbstractData.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespace Magento\Customer\Model\Metadata\Form;
1212

1313
use Magento\Framework\Api\ArrayObjectSearch;
14+
use Magento\Framework\Validator\EmailAddress;
1415

1516
/**
1617
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -336,7 +337,7 @@ protected function _validateInputRule($value)
336337
__("'%value%' appears to be a DNS hostname but cannot extract TLD part")
337338
__("'%value%' appears to be a DNS hostname but cannot match TLD against known list")
338339
*/
339-
$validator = new \Zend_Validate_EmailAddress();
340+
$validator = new EmailAddress();
340341
$validator->setMessage(
341342
__('"%1" invalid type entered.', $label),
342343
\Zend_Validate_EmailAddress::INVALID
@@ -377,10 +378,6 @@ protected function _validateInputRule($value)
377378
__("'%value%' looks like an IP address, which is not an acceptable format."),
378379
\Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED
379380
);
380-
$validator->setMessage(
381-
__("'%value%' looks like a DNS hostname but we cannot match the TLD against known list."),
382-
\Zend_Validate_Hostname::UNKNOWN_TLD
383-
);
384381
$validator->setMessage(
385382
__("'%value%' looks like a DNS hostname but contains a dash in an invalid position."),
386383
\Zend_Validate_Hostname::INVALID_DASH

app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ protected function _checkUniqueKey(array $rowData, $rowNumber)
235235
$email = strtolower($rowData[static::COLUMN_EMAIL]);
236236
$website = $rowData[static::COLUMN_WEBSITE];
237237

238-
if (!\Zend_Validate::is($email, 'EmailAddress')) {
238+
if (!\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) {
239239
$this->addRowError(static::ERROR_INVALID_EMAIL, $rowNumber, static::COLUMN_EMAIL);
240240
} elseif (!isset($this->_websiteCodeToId[$website])) {
241241
$this->addRowError(static::ERROR_INVALID_WEBSITE, $rowNumber, static::COLUMN_WEBSITE);

app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Magento\Framework\App\RequestInterface;
1212
use Magento\Framework\Exception\LocalizedException as CoreException;
13+
use Magento\Framework\Validator\EmailAddress;
1314

1415
/**
1516
* EAV Attribute Abstract Data Model
@@ -365,7 +366,7 @@ protected function _validateInputRule($value)
365366
__("'%value%' appears to be a DNS hostname but cannot extract TLD part")
366367
__("'%value%' appears to be a DNS hostname but cannot match TLD against known list")
367368
*/
368-
$validator = new \Zend_Validate_EmailAddress();
369+
$validator = new EmailAddress();
369370
$validator->setMessage(
370371
__('"%1" invalid type entered.', $label),
371372
\Zend_Validate_EmailAddress::INVALID
@@ -406,10 +407,6 @@ protected function _validateInputRule($value)
406407
__("'%value%' looks like an IP address, which is not an acceptable format."),
407408
\Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED
408409
);
409-
$validator->setMessage(
410-
__("'%value%' looks like a DNS hostname but we cannot match the TLD against known list."),
411-
\Zend_Validate_Hostname::UNKNOWN_TLD
412-
);
413410
$validator->setMessage(
414411
__("'%value%' looks like a DNS hostname but contains a dash in an invalid position."),
415412
\Zend_Validate_Hostname::INVALID_DASH

app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ protected function validateGuestSubscription()
103103
*/
104104
protected function validateEmailFormat($email)
105105
{
106-
if (!\Zend_Validate::is($email, 'EmailAddress')) {
106+
if (!\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) {
107107
throw new \Magento\Framework\Exception\LocalizedException(__('Please enter a valid email address.'));
108108
}
109109
}

app/code/Magento/Quote/Model/Quote/Address/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function isValid($value)
3939
{
4040
$messages = [];
4141
$email = $value->getEmail();
42-
if (!empty($email) && !\Zend_Validate::is($email, 'EmailAddress')) {
42+
if (!empty($email) && !\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) {
4343
$messages['invalid_email_format'] = 'Invalid email format';
4444
}
4545

app/code/Magento/SendFriend/Model/SendFriend.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public function validate()
237237
}
238238

239239
$email = $this->getSender()->getEmail();
240-
if (empty($email) or !\Zend_Validate::is($email, 'EmailAddress')) {
240+
if (empty($email) or !\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) {
241241
$errors[] = __('Invalid Sender Email');
242242
}
243243

@@ -252,7 +252,7 @@ public function validate()
252252

253253
// validate recipients email addresses
254254
foreach ($this->getRecipients()->getEmails() as $email) {
255-
if (!\Zend_Validate::is($email, 'EmailAddress')) {
255+
if (!\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) {
256256
$errors[] = __('Please enter a correct recipient email address.');
257257
break;
258258
}

app/code/Magento/User/Controller/Adminhtml/Auth/Forgotpassword.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function execute()
4444
$resultRedirect = $this->resultRedirectFactory->create();
4545
if (!empty($email) && !empty($params)) {
4646
// Validate received data to be an email address
47-
if (\Zend_Validate::is($email, 'EmailAddress')) {
47+
if (\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) {
4848
try {
4949
$this->securityManager->performSecurityCheck(
5050
\Magento\Security\Model\PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST,

app/code/Magento/Wishlist/Controller/Index/Send.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function execute()
153153
} else {
154154
foreach ($emails as $index => $email) {
155155
$email = trim($email);
156-
if (!\Zend_Validate::is($email, 'EmailAddress')) {
156+
if (!\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) {
157157
$error = __('Please enter a valid email address.');
158158
break;
159159
}

0 commit comments

Comments
 (0)