diff --git a/lib/Controller/ArchiveController.php b/lib/Controller/ArchiveController.php index 51c393d7..aafd0662 100644 --- a/lib/Controller/ArchiveController.php +++ b/lib/Controller/ArchiveController.php @@ -134,7 +134,7 @@ class ArchiveController extends GenericApiController } else { // file not in archive, put it in there $af = \OCA\Memories\Util::$ARCHIVE_FOLDER; - $destinationPath = Exif::removeExtraSlash($af.$relativeFilePath); + $destinationPath = Exif::sanitizePath($af.$relativeFilePath); } // Remove the filename diff --git a/lib/Db/FsManager.php b/lib/Db/FsManager.php index cc0fdec9..8c92ec37 100644 --- a/lib/Db/FsManager.php +++ b/lib/Db/FsManager.php @@ -103,13 +103,13 @@ class FsManager try { if (null !== $folderPath) { - $folder = $userFolder->get(Exif::removeExtraSlash($folderPath)); + $folder = $userFolder->get(Exif::sanitizePath($folderPath)); $root->addFolder($folder); } else { // Get timeline paths $paths = Exif::getTimelinePaths($uid); if ($path = $this->request->getParam('timelinePath', null)) { - $paths = [Exif::removeExtraSlash($path)]; + $paths = [Exif::sanitizePath($path)]; } // Combined etag, for cache invalidation. diff --git a/lib/Exif.php b/lib/Exif.php index d65448b0..835248bf 100644 --- a/lib/Exif.php +++ b/lib/Exif.php @@ -81,15 +81,9 @@ class Exif */ public static function sanitizePath(string $path) { - return mb_ereg_replace('([^\\w\\s\\d\\-_~,;:!@#$&*{}\[\]\'\\[\\]\\(\\).\\\/])', '', $path); - } - - /** - * Keep only one slash if multiple repeating. - */ - public static function removeExtraSlash(string $path) - { - return mb_ereg_replace('\/\/+', '/', $path); + $path = mb_ereg_replace('([^\\w\\s\\d\\-_~,;:!@#$&*{}\[\]\'\\[\\]\\(\\).\\\/])', '', $path); + $path = mb_ereg_replace('\/\/+', '/', $path); // remove extra slashes + return $path; } /**