Skip to content

Commit 49bc648

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-85126' into 2.3-develop-pr3
2 parents 9de876e + 2d87951 commit 49bc648

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

app/code/Magento/ImportExport/Helper/Report.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,14 @@ public function getReportSize($filename)
121121
*
122122
* @param string $filename
123123
* @return string
124+
* @throws \InvalidArgumentException
124125
*/
125126
protected function getFilePath($filename)
126127
{
128+
if (preg_match('/\.\.(\\\|\/)/', $filename)) {
129+
throw new \InvalidArgumentException('Filename has not permitted symbols in it');
130+
}
131+
127132
return $this->varDirectory->getRelativePath(Import::IMPORT_HISTORY_DIR . $filename);
128133
}
129134

app/code/Magento/ImportExport/Test/Unit/Helper/ReportTest.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,38 @@ public function testGetSummaryStats()
147147
$this->assertInstanceOf(\Magento\Framework\Phrase::class, $message);
148148
}
149149

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+
150162
public function testImportFileExists()
151163
{
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+
];
153182
}
154183

155184
/**

0 commit comments

Comments
 (0)