Skip to content

Commit d1b06c8

Browse files
authored
Merge pull request #5414 from magento-tsg-csl3/2.3-develop-pr38
[TSG-CSL3] For 2.3 (pr38)
2 parents 8c1dfb4 + 52a52d9 commit d1b06c8

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product/Validator.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
use Magento\Catalog\Model\Product\Attribute\Backend\Sku;
1111

1212
/**
13-
* Class Validator
13+
* Product import model validator
1414
*
1515
* @api
1616
* @since 100.0.2
1717
*/
1818
class Validator extends AbstractValidator implements RowValidatorInterface
1919
{
20+
private const ERROR_SKU_MARGINAL_WHITESPACES = "Sku contains marginal whitespaces";
21+
2022
/**
2123
* @var RowValidatorInterface[]|AbstractValidator[]
2224
*/
@@ -72,8 +74,12 @@ protected function textValidation($attrCode, $type)
7274
$val = $this->string->cleanString($this->_rowData[$attrCode]);
7375
if ($type == 'text') {
7476
$valid = $this->string->strlen($val) < Product::DB_MAX_TEXT_LENGTH;
75-
} else if ($attrCode == Product::COL_SKU) {
77+
} elseif ($attrCode == Product::COL_SKU) {
7678
$valid = $this->string->strlen($val) <= SKU::SKU_MAX_LENGTH;
79+
if ($this->string->strlen($val) !== $this->string->strlen(trim($val))) {
80+
$this->_addMessages([self::ERROR_SKU_MARGINAL_WHITESPACES]);
81+
return false;
82+
}
7783
} else {
7884
$valid = $this->string->strlen($val) < Product::DB_MAX_VARCHAR_LENGTH;
7985
}
@@ -359,5 +365,7 @@ public function init($context)
359365
foreach ($this->validators as $validator) {
360366
$validator->init($context);
361367
}
368+
369+
return $this;
362370
}
363371
}

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,10 +1045,10 @@ private function changePasswordForCustomer($customer, $currentPassword, $newPass
10451045
}
10461046
$customerEmail = $customer->getEmail();
10471047
$this->credentialsValidator->checkPasswordDifferentFromEmail($customerEmail, $newPassword);
1048+
$this->checkPasswordStrength($newPassword);
10481049
$customerSecure = $this->customerRegistry->retrieveSecureData($customer->getId());
10491050
$customerSecure->setRpToken(null);
10501051
$customerSecure->setRpTokenCreatedAt(null);
1051-
$this->checkPasswordStrength($newPassword);
10521052
$customerSecure->setPasswordHash($this->createPasswordHash($newPassword));
10531053
$this->destroyCustomerSessions($customer->getId());
10541054
$this->disableAddressValidation($customer);
@@ -1630,6 +1630,7 @@ private function getEmailNotification()
16301630
*/
16311631
private function destroyCustomerSessions($customerId)
16321632
{
1633+
$this->sessionManager->regenerateId();
16331634
$sessionLifetime = $this->scopeConfig->getValue(
16341635
\Magento\Framework\Session\Config::XML_PATH_COOKIE_LIFETIME,
16351636
\Magento\Store\Model\ScopeInterface::SCOPE_STORE

app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,7 @@ public function testChangePassword()
15511551
->with($customer);
15521552

15531553
$this->sessionManager->expects($this->atLeastOnce())->method('getSessionId');
1554+
$this->sessionManager->expects($this->atLeastOnce())->method('regenerateId');
15541555

15551556
$visitor = $this->getMockBuilder(\Magento\Customer\Model\Visitor::class)
15561557
->disableOriginalConstructor()
@@ -1628,6 +1629,7 @@ function ($string) {
16281629

16291630
$this->sessionManager->method('isSessionExists')->willReturn(false);
16301631
$this->sessionManager->expects($this->atLeastOnce())->method('getSessionId');
1632+
$this->sessionManager->expects($this->atLeastOnce())->method('regenerateId');
16311633
$visitor = $this->getMockBuilder(\Magento\Customer\Model\Visitor::class)
16321634
->disableOriginalConstructor()
16331635
->setMethods(['getSessionId'])

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,6 +2416,16 @@ public function validateRowDataProvider()
24162416
'behavior' => Import::BEHAVIOR_REPLACE,
24172417
'expectedResult' => true,
24182418
],
2419+
[
2420+
'row' => ['sku' => 'sku with whitespace ',
2421+
'name' => 'Test',
2422+
'product_type' => 'simple',
2423+
'_attribute_set' => 'Default',
2424+
'price' => 10.20,
2425+
],
2426+
'behavior' => Import::BEHAVIOR_ADD_UPDATE,
2427+
'expectedResult' => false,
2428+
],
24192429
];
24202430
}
24212431

0 commit comments

Comments
 (0)