File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed
app/code/Magento/ImportExport Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -121,9 +121,14 @@ public function getReportSize($filename)
121
121
*
122
122
* @param string $filename
123
123
* @return string
124
+ * @throws \InvalidArgumentException
124
125
*/
125
126
protected function getFilePath ($ filename )
126
127
{
128
+ if (preg_match ('/\.\.( \\\|\/)/ ' , $ filename )) {
129
+ throw new \InvalidArgumentException ('Filename has not permitted symbols in it ' );
130
+ }
131
+
127
132
return $ this ->varDirectory ->getRelativePath (Import::IMPORT_HISTORY_DIR . $ filename );
128
133
}
129
134
Original file line number Diff line number Diff line change @@ -147,9 +147,38 @@ public function testGetSummaryStats()
147
147
$ this ->assertInstanceOf (\Magento \Framework \Phrase::class, $ message );
148
148
}
149
149
150
+ /**
151
+ * @dataProvider importFileExistsDataProvider
152
+ * @expectedException \InvalidArgumentException
153
+ * @expectedExceptionMessage Filename has not permitted symbols in it
154
+ * @param string $fileName
155
+ * return void
156
+ */
157
+ public function testImportFileExistsException ($ fileName )
158
+ {
159
+ $ this ->report ->importFileExists ($ fileName );
160
+ }
161
+
150
162
public function testImportFileExists ()
151
163
{
152
- $ this ->assertEquals ($ this ->report ->importFileExists ('file ' ), true );
164
+ $ this ->assertEquals ($ this ->report ->importFileExists ('..file..name ' ), true );
165
+ }
166
+
167
+ /**
168
+ * Dataprovider for testImportFileExistsException()
169
+ *
170
+ * @return array
171
+ */
172
+ public function importFileExistsDataProvider ()
173
+ {
174
+ return [
175
+ [
176
+ 'fileName ' => 'some_folder/../another_folder ' ,
177
+ ],
178
+ [
179
+ 'fileName ' => 'some_folder\..\another_folder ' ,
180
+ ]
181
+ ];
153
182
}
154
183
155
184
/**
You can’t perform that action at this time.
0 commit comments