Skip to content

Commit 2f77c8f

Browse files
author
Lysenko Olexandr
authored
Merge pull request #3736 from magento-chaika/chaika_february
chaika_february
2 parents f211371 + 5b3afb5 commit 2f77c8f

File tree

6 files changed

+91
-58
lines changed

6 files changed

+91
-58
lines changed

app/code/Magento/Catalog/Block/Product/View/Attributes.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Magento\Framework\Pricing\PriceCurrencyInterface;
1717

1818
/**
19+
* Attributes attributes block
20+
*
1921
* @api
2022
* @since 100.0.2
2123
*/
@@ -56,6 +58,8 @@ public function __construct(
5658
}
5759

5860
/**
61+
* Returns a Product
62+
*
5963
* @return Product
6064
*/
6165
public function getProduct()
@@ -88,7 +92,7 @@ public function getAdditionalData(array $excludeAttr = [])
8892
$value = $this->priceCurrency->convertAndFormat($value);
8993
}
9094

91-
if (is_string($value) && strlen($value)) {
95+
if (is_string($value) && strlen(trim($value))) {
9296
$data[$attribute->getAttributeCode()] = [
9397
'label' => __($attribute->getStoreLabel()),
9498
'value' => $value,

app/code/Magento/Customer/Block/Adminhtml/Edit/Renderer/Region.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
4848

4949
$regionId = $element->getForm()->getElement('region_id')->getValue();
5050

51-
$html = '<div class="field field-state required admin__field _required">';
51+
$html = '<div class="field field-state admin__field">';
5252
$element->setClass('input-text admin__control-text');
5353
$element->setRequired(true);
5454
$html .= $element->getLabelHtml() . '<div class="control admin__field-control">';

lib/internal/Magento/Framework/Encryption/Adapter/SodiumChachaIetf.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function __construct(
3333
*
3434
* @param string $data
3535
* @return string string
36+
* @throws \SodiumException
3637
*/
3738
public function encrypt(string $data): string
3839
{
@@ -58,13 +59,17 @@ public function decrypt(string $data): string
5859
$nonce = mb_substr($data, 0, SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES, '8bit');
5960
$payload = mb_substr($data, SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES, null, '8bit');
6061

61-
$plainText = sodium_crypto_aead_chacha20poly1305_ietf_decrypt(
62-
$payload,
63-
$nonce,
64-
$nonce,
65-
$this->key
66-
);
62+
try {
63+
$plainText = sodium_crypto_aead_chacha20poly1305_ietf_decrypt(
64+
$payload,
65+
$nonce,
66+
$nonce,
67+
$this->key
68+
);
69+
} catch (\SodiumException $e) {
70+
$plainText = '';
71+
}
6772

68-
return $plainText;
73+
return $plainText !== false ? $plainText : '';
6974
}
7075
}

lib/internal/Magento/Framework/Encryption/Test/Unit/Adapter/SodiumChachaIetfTest.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@
1111
*/
1212
namespace Magento\Framework\Encryption\Test\Unit\Adapter;
1313

14-
class SodiumChachaIetfTest extends \PHPUnit\Framework\TestCase
14+
use Magento\Framework\Encryption\Adapter\SodiumChachaIetf;
15+
use PHPUnit\Framework\TestCase;
16+
17+
class SodiumChachaIetfTest extends TestCase
1518
{
19+
/**
20+
* @return array
21+
*/
1622
public function getCryptData(): array
1723
{
18-
$fixturesFilename = __DIR__ . '/../Crypt/_files/_sodium_chachaieft_fixtures.php';
19-
20-
$result = include $fixturesFilename;
24+
$result = include __DIR__ . '/../Crypt/_files/_sodium_chachaieft_fixtures.php';
2125
/* Restore encoded string back to binary */
2226
foreach ($result as &$cryptParams) {
2327
$cryptParams['encrypted'] = base64_decode($cryptParams['encrypted']);
@@ -29,21 +33,30 @@ public function getCryptData(): array
2933

3034
/**
3135
* @dataProvider getCryptData
36+
*
37+
* @param string $key
38+
* @param string $encrypted
39+
* @param string $decrypted
40+
* @throws \SodiumException
3241
*/
33-
public function testEncrypt(string $key, string $encrypted, string $decrypted)
42+
public function testEncrypt(string $key, string $encrypted, string $decrypted): void
3443
{
35-
$crypt = new \Magento\Framework\Encryption\Adapter\SodiumChachaIetf($key);
44+
$crypt = new SodiumChachaIetf($key);
3645
$result = $crypt->encrypt($decrypted);
3746

3847
$this->assertNotEquals($encrypted, $result);
3948
}
4049

4150
/**
4251
* @dataProvider getCryptData
52+
*
53+
* @param string $key
54+
* @param string $encrypted
55+
* @param string $decrypted
4356
*/
44-
public function testDecrypt(string $key, string $encrypted, string $decrypted)
57+
public function testDecrypt(string $key, string $encrypted, string $decrypted): void
4558
{
46-
$crypt = new \Magento\Framework\Encryption\Adapter\SodiumChachaIetf($key);
59+
$crypt = new SodiumChachaIetf($key);
4760
$result = $crypt->decrypt($encrypted);
4861

4962
$this->assertEquals($decrypted, $result);

lib/internal/Magento/Framework/Encryption/Test/Unit/Crypt/_files/_sodium_chachaieft_fixtures.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,14 @@
3232
'encrypted' => 'UglO9dEgslFpwPwejJmrK89PmBicv+I1pfdaXaEI69IrETD8LpdzOLF7',
3333
'decrypted' => 'Hello World!!!',
3434
],
35+
5 => [
36+
'key' => '6wRADHwwCBGgdxbcHhovGB0upmg0mbsN',
37+
'encrypted' => '',
38+
'decrypted' => '',
39+
],
40+
6 => [
41+
'key' => '6wRADHwwCBGgdxbcHhovGB0upmg0mbsN',
42+
'encrypted' => 'bWFsZm9ybWVkLWlucHV0',
43+
'decrypted' => '',
44+
],
3545
];

0 commit comments

Comments
 (0)