mirror of
https://github.com/filegator/filegator.git
synced 2025-08-01 03:20:30 +02:00
Two consecutive periods bug - fixes #202
This commit is contained in:
@@ -235,8 +235,11 @@ class Filesystem implements Service
|
|||||||
|
|
||||||
private function applyPathPrefix(string $path): string
|
private function applyPathPrefix(string $path): string
|
||||||
{
|
{
|
||||||
if (strpos($path, '..') !== false) {
|
if ($path == '..'
|
||||||
$path = "/";
|
|| strpos($path, '..'.$this->separator) !== false
|
||||||
|
|| strpos($path, $this->separator.'..') !== false
|
||||||
|
) {
|
||||||
|
$path = $this->separator;
|
||||||
}
|
}
|
||||||
return $this->joinPaths($this->getPathPrefix(), $path);
|
return $this->joinPaths($this->getPathPrefix(), $path);
|
||||||
}
|
}
|
||||||
|
@@ -403,6 +403,8 @@ class FilesystemTest extends TestCase
|
|||||||
$this->assertEquals('/john/test.txt/', $this->invokeMethod($this->storage, 'applyPathPrefix', ['test.txt/']));
|
$this->assertEquals('/john/test.txt/', $this->invokeMethod($this->storage, 'applyPathPrefix', ['test.txt/']));
|
||||||
// no escaping path to upper dir
|
// no escaping path to upper dir
|
||||||
$this->assertEquals('/john/', $this->invokeMethod($this->storage, 'applyPathPrefix', ['/..']));
|
$this->assertEquals('/john/', $this->invokeMethod($this->storage, 'applyPathPrefix', ['/..']));
|
||||||
|
$this->assertEquals('/john/', $this->invokeMethod($this->storage, 'applyPathPrefix', ['..']));
|
||||||
|
$this->assertEquals('/john/', $this->invokeMethod($this->storage, 'applyPathPrefix', ['../']));
|
||||||
$this->assertEquals('/john/', $this->invokeMethod($this->storage, 'applyPathPrefix', ['/sub/../../']));
|
$this->assertEquals('/john/', $this->invokeMethod($this->storage, 'applyPathPrefix', ['/sub/../../']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user