From a4d57b99f4163ca929433f20d56630e99f234a54 Mon Sep 17 00:00:00 2001 From: Eden Date: Wed, 4 Dec 2019 22:50:34 +0700 Subject: [PATCH 1/3] Resolve issue 25896: Cannot create folder using only letters --- .../Magento/Cms/Model/Wysiwyg/Images/Storage.php | 2 +- .../Unit/Model/Wysiwyg/Images/StorageTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php index e02d2b461a94e..21f3b232e783c 100644 --- a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php +++ b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php @@ -416,7 +416,7 @@ public function createDirectory($name, $path) { if (!preg_match(self::DIRECTORY_NAME_REGEXP, $name)) { throw new \Magento\Framework\Exception\LocalizedException( - __('Please rename the folder using only letters, numbers, underscores and dashes.') + __('Please rename the folder using only Latin letters, numbers, underscores and dashes.') ); } diff --git a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php index 662aee671dd24..9a9c63195051c 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php @@ -7,6 +7,7 @@ use Magento\Cms\Model\Wysiwyg\Images\Storage\Collection as StorageCollection; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Exception\LocalizedException; /** * @SuppressWarnings(PHPMD.LongVariable) @@ -539,4 +540,18 @@ public function testUploadFile() $this->assertEquals($result, $this->imagesStorage->uploadFile($targetPath, $type)); } + + /** + * Test create directory with invalid name + */ + public function testCreateDirectoryWithInvalidName() + { + $name = 'папка'; + $path = '/tmp/path'; + $this->expectException(LocalizedException::class); + $this->expectExceptionMessage( + (string)__('Please rename the folder using only Latin letters, numbers, underscores and dashes.') + ); + $this->imagesStorage->createDirectory($name, $path); + } } From 721f8cedc063e405074c0ceaea200f0c44f905eb Mon Sep 17 00:00:00 2001 From: Eden Date: Tue, 10 Dec 2019 21:53:06 +0700 Subject: [PATCH 2/3] Update .csv for issue 25896 --- app/code/Magento/Cms/i18n/en_US.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Cms/i18n/en_US.csv b/app/code/Magento/Cms/i18n/en_US.csv index 2947c567d75ff..6a623f947cbc2 100644 --- a/app/code/Magento/Cms/i18n/en_US.csv +++ b/app/code/Magento/Cms/i18n/en_US.csv @@ -75,7 +75,7 @@ Pages,Pages "A block identifier with the same properties already exists in the selected store.","A block identifier with the same properties already exists in the selected store." "The page URL key contains capital letters or disallowed symbols.","The page URL key contains capital letters or disallowed symbols." "The page URL key cannot be made of only numbers.","The page URL key cannot be made of only numbers." -"Please rename the folder using only letters, numbers, underscores and dashes.","Please rename the folder using only letters, numbers, underscores and dashes." +"Please rename the folder using only Latin letters, numbers, underscores and dashes.","Please rename the folder using only Latin letters, numbers, underscores and dashes." "We found a directory with the same name. Please try another folder name.","We found a directory with the same name. Please try another folder name." "We cannot create a new directory.","We cannot create a new directory." "We cannot delete directory %1.","We cannot delete directory %1." From 17a575a1ed64b6c74d969051877f01e25621ef58 Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun Date: Tue, 10 Dec 2019 18:23:11 +0200 Subject: [PATCH 3/3] Restore the translatable phrase for backward compatibility --- app/code/Magento/Cms/i18n/en_US.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Cms/i18n/en_US.csv b/app/code/Magento/Cms/i18n/en_US.csv index 6a623f947cbc2..b860a8fb1041e 100644 --- a/app/code/Magento/Cms/i18n/en_US.csv +++ b/app/code/Magento/Cms/i18n/en_US.csv @@ -75,6 +75,7 @@ Pages,Pages "A block identifier with the same properties already exists in the selected store.","A block identifier with the same properties already exists in the selected store." "The page URL key contains capital letters or disallowed symbols.","The page URL key contains capital letters or disallowed symbols." "The page URL key cannot be made of only numbers.","The page URL key cannot be made of only numbers." +"Please rename the folder using only letters, numbers, underscores and dashes.","Please rename the folder using only letters, numbers, underscores and dashes." "Please rename the folder using only Latin letters, numbers, underscores and dashes.","Please rename the folder using only Latin letters, numbers, underscores and dashes." "We found a directory with the same name. Please try another folder name.","We found a directory with the same name. Please try another folder name." "We cannot create a new directory.","We cannot create a new directory."