File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images
dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ public function execute()
82
82
$ filesystem = $ this ->_objectManager ->get (\Magento \Framework \Filesystem::class);
83
83
$ dir = $ filesystem ->getDirectoryRead (DirectoryList::MEDIA );
84
84
$ filePath = $ path . '/ ' . \Magento \Framework \File \Uploader::getCorrectFileName ($ file );
85
- if ($ dir ->isFile ($ dir ->getRelativePath ($ filePath ))) {
85
+ if ($ dir ->isFile ($ dir ->getRelativePath ($ filePath )) && ! preg_match ( ' #.htaccess# ' , $ file ) ) {
86
86
$ this ->getStorage ()->deleteFile ($ filePath );
87
87
}
88
88
}
Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ protected function setUp()
54
54
$ filePath = $ this ->fullDirectoryPath . DIRECTORY_SEPARATOR . $ this ->fileName ;
55
55
$ fixtureDir = realpath (__DIR__ . '/../../../../../Catalog/_files ' );
56
56
copy ($ fixtureDir . '/ ' . $ this ->fileName , $ filePath );
57
+ $ path = '/.htaccess ' ;
58
+ if (!$ this ->mediaDirectory ->isFile ($ path )) {
59
+ $ this ->mediaDirectory ->writeFile ($ path , "Order deny,allow \nDeny from all " );
60
+ }
57
61
$ this ->model = $ objectManager ->get (\Magento \Cms \Controller \Adminhtml \Wysiwyg \Images \DeleteFiles::class);
58
62
}
59
63
@@ -89,4 +93,24 @@ public static function tearDownAfterClass()
89
93
$ directory ->delete ('wysiwyg ' );
90
94
}
91
95
}
96
+
97
+ /**
98
+ * Check that htaccess file couldn't be removed via
99
+ * \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images\DeleteFiles::execute method
100
+ *
101
+ * @return void
102
+ */
103
+ public function testDeleteHtaccess ()
104
+ {
105
+ $ this ->model ->getRequest ()->setMethod ('POST ' )
106
+ ->setPostValue ('files ' , [$ this ->imagesHelper ->idEncode ('.htaccess ' )]);
107
+ $ this ->model ->getStorage ()->getSession ()->setCurrentPath ($ this ->fullDirectoryPath );
108
+ $ this ->model ->execute ();
109
+
110
+ $ this ->assertTrue (
111
+ $ this ->mediaDirectory ->isExist (
112
+ $ this ->mediaDirectory ->getRelativePath ('/ ' . '.htaccess ' )
113
+ )
114
+ );
115
+ }
92
116
}
You can’t perform that action at this time.
0 commit comments