public: fix extra slash in path (fix #716)
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/803/head
parent
77a557547e
commit
4122f592b6
|
@ -196,9 +196,10 @@ class PublicController extends AuthPublicShareController
|
||||||
$relPath = substr($node->getPath(), \strlen($userFolder->getPath()));
|
$relPath = substr($node->getPath(), \strlen($userFolder->getPath()));
|
||||||
|
|
||||||
// Get the user's folders path
|
// Get the user's folders path
|
||||||
$foldersPath = $this->config->getUserValue($user->getUID(), Application::APPNAME, 'foldersPath', '');
|
$foldersPath = $this->config->getUserValue($user->getUID(), Application::APPNAME, 'foldersPath', null) ?: '/';
|
||||||
$foldersPath = $foldersPath ?: '/';
|
|
||||||
$foldersPath = Util::sanitizePath($foldersPath);
|
// Sanitize folders path ensuring leading and trailing slashes
|
||||||
|
$foldersPath = Util::sanitizePath('/' . $foldersPath . '/');
|
||||||
|
|
||||||
// Check if relPath starts with foldersPath
|
// Check if relPath starts with foldersPath
|
||||||
if (0 !== strpos($relPath, $foldersPath)) {
|
if (0 !== strpos($relPath, $foldersPath)) {
|
||||||
|
|
|
@ -324,7 +324,7 @@ class Util
|
||||||
/**
|
/**
|
||||||
* Sanitize a path to keep only ASCII characters and special characters.
|
* Sanitize a path to keep only ASCII characters and special characters.
|
||||||
*/
|
*/
|
||||||
public static function sanitizePath(string $path)
|
public static function sanitizePath(string $path): string
|
||||||
{
|
{
|
||||||
$path = str_replace("\0", '', $path); // remove null characters
|
$path = str_replace("\0", '', $path); // remove null characters
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue