Skip to content

Commit a161858

Browse files
committed
MAGETWO-70735: [UX][Security] Missing validation and hint for "Compatible File Extensions" in Custom Option of Type=File
1 parent 0cfd054 commit a161858

File tree

6 files changed

+201
-206
lines changed

6 files changed

+201
-206
lines changed

app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ public function testCleanFileExtensions(string $rawExtensions, string $expectedE
8282
$this->model->setFileExtension($rawExtensions);
8383
$this->model->beforeSave();
8484
$actualExtensions = $this->model->getFileExtension();
85-
$this->assertEquals(
86-
$expectedExtensions,
87-
$actualExtensions
88-
);
85+
$this->assertEquals($expectedExtensions, $actualExtensions);
8986
}
9087

9188
/**
@@ -102,7 +99,7 @@ public function cleanFileExtensionsDataProvider()
10299
['jpg png gif', 'jpg, png, gif'],
103100
['!jpg@png#gif%', 'jpg, png, gif'],
104101
['jpg, png, 123', 'jpg, png, 123'],
105-
['', '']
102+
['', ''],
106103
];
107104
}
108105
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ protected function getFileExtensionFieldConfig($sortOrder)
10461046
'data' => [
10471047
'config' => [
10481048
'label' => __('Compatible File Extensions'),
1049-
'notice' => __('Enter separated extensions, like: png, jpg, gif. Leave blank to allow any.'),
1049+
'notice' => __('Enter separated extensions, like: png, jpg, gif.'),
10501050
'componentType' => Field::NAME,
10511051
'formElement' => Input::NAME,
10521052
'dataScope' => static::FIELD_FILE_EXTENSION_NAME,

dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCustomOptions.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class AssertCustomOptions extends AssertProductForm
1717
{
1818
/**
19-
* Assert form data equals fixture data
19+
* Assert form data equals fixture data.
2020
*
2121
* @param FixtureInterface $product
2222
* @param CatalogProductIndex $productGrid
@@ -38,8 +38,9 @@ public function processAssert(
3838
}
3939
$fixtureData = $this->prepareFixtureData($productData, $this->sortFields);
4040
$formData = $this->prepareFormData($productPage->getProductForm()->getData($product), $this->sortFields);
41-
$error = $this->verifyData($fixtureData, $formData);
42-
\PHPUnit\Framework\Assert::assertTrue(empty($error), $error);
41+
$errors = $this->verifyData($fixtureData, $formData);
42+
43+
\PHPUnit\Framework\Assert::assertEmpty($errors, $errors);
4344
}
4445

4546
/**

dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertFileExtensionHints.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class AssertFileExtensionHints extends AbstractAssertForm
2020
*
2121
* @var string
2222
*/
23-
const EXPECTED_MESSAGE = 'Enter separated extensions, like: png, jpg, gif. Leave blank to allow any.';
23+
const EXPECTED_MESSAGE = 'Enter separated extensions, like: png, jpg, gif.';
2424

2525
/**
2626
* Assert that file extension message is showed.

0 commit comments

Comments
 (0)