From 4dd7ca30e36a4f4a8fe6158f3e9258c8efdd02cd Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 10 May 2024 13:13:38 +0800 Subject: [PATCH] Prevent double slashes in group folder path parsing Signed-off-by: Claudio Cambra --- src/gui/tray/usermodel.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index f217f6ac6..914517672 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -339,15 +339,22 @@ void User::parseNewGroupFolderPath(const QString &mountPoint) if (mountPoint.isEmpty()) { return; } - auto mountPointSplit = mountPoint.split(QLatin1Char('/'), Qt::SkipEmptyParts); + + auto sanitisedMountPoint = mountPoint; + sanitisedMountPoint.replace("//", "/"); + auto mountPointSplit = sanitisedMountPoint.split('/', Qt::SkipEmptyParts); if (mountPointSplit.isEmpty()) { return; } const auto groupFolderName = mountPointSplit.takeLast(); - const auto parentPath = mountPointSplit.join(QLatin1Char('/')); - _trayFolderInfos.push_back(QVariant::fromValue(TrayFolderInfo{groupFolderName, parentPath, mountPoint, TrayFolderInfo::GroupFolder})); + const auto parentPath = mountPointSplit.join('/'); + const auto folderInfo = TrayFolderInfo( + groupFolderName, parentPath, sanitisedMountPoint, TrayFolderInfo::GroupFolder + ); + const auto folderInfoVariant = QVariant::fromValue(folderInfo); + _trayFolderInfos.push_back(folderInfoVariant); } void User::prePendGroupFoldersWithLocalFolder()