Skip to content

Commit b5a3c2a

Browse files
Merge pull request #3 from demvsystems/fix-double-separator
fix double separator in filepath
2 parents 0866828 + 2bdda51 commit b5a3c2a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/TmpDirRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function createFileInSystemTmp(string $dir, string $filename): string
9797
throw new RuntimeException('Can\'t read info from filename.');
9898
}
9999

100-
$filepath = $dir . DIRECTORY_SEPARATOR . sprintf('%s_%s.%s', $info['filename'], $this->getUniqid(), $info['extension']);
100+
$filepath = self::addSeperatorIfNecessary($dir . DIRECTORY_SEPARATOR) . sprintf('%s_%s.%s', $info['filename'], $this->getUniqid(), $info['extension']);
101101
$handle = fopen($filepath, 'wb+');
102102
fclose($handle);
103103
if (!file_exists($filepath)) {

tests/TmpDirRegistryTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ public function testCreateFileInSystemTmpFilename(): void
9595
self::assertTrue(strlen($filename) < strlen($uniqueFilename));
9696
}
9797

98+
public function testCreateFileInSystemTmpHasOnlyOneSeperator(): void
99+
{
100+
$dirname = $this->instance->createDirInSystemTmp('testdirectory');
101+
$filename = 'testfilename.txt';
102+
$uniqueFilename = $this->instance->createFileInSystemTmp($dirname, $filename);
103+
104+
self::assertNotContains('//', $uniqueFilename);
105+
}
106+
98107
public function testCreateFileInSystemTmp(): void
99108
{
100109
$dirname = 'testdirectory';

0 commit comments

Comments
 (0)