Skip to content

Commit 9d64d01

Browse files
committed
Merge remote-tracking branch 'mainline/2.3.3-develop' into MC-15977
2 parents 76b64db + 6fa79f0 commit 9d64d01

File tree

2 files changed

+8
-2
lines changed
  • app/code/Magento/ImportExport/Model
  • dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Import

2 files changed

+8
-2
lines changed

app/code/Magento/ImportExport/Model/Import.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,15 @@ public function uploadSource()
568568
$entity = $this->getEntity();
569569
/** @var $uploader Uploader */
570570
$uploader = $this->_uploaderFactory->create(['fileId' => self::FIELD_NAME_SOURCE_FILE]);
571+
$uploader->setAllowedExtensions(['csv', 'zip']);
571572
$uploader->skipDbProcessing(true);
572573
$fileName = $this->random->getRandomString(32) . '.' . $uploader->getFileExtension();
573-
$result = $uploader->save($this->getWorkingDir(), $fileName);
574+
try {
575+
$result = $uploader->save($this->getWorkingDir(), $fileName);
576+
} catch (\Exception $e) {
577+
throw new LocalizedException(__('The file cannot be uploaded.'));
578+
}
579+
574580
// phpcs:disable Magento2.Functions.DiscouragedFunction.Discouraged
575581
$extension = pathinfo($result['file'], PATHINFO_EXTENSION);
576582

dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Import/ValidateTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function validationDataProvider(): array
9393
[
9494
'file_name' => 'test.txt',
9595
'mime-type' => 'text/csv',
96-
'message' => '\'txt\' file extension is not supported',
96+
'message' => 'The file cannot be uploaded.',
9797
'delimiter' => ',',
9898
],
9999
[

0 commit comments

Comments
 (0)