From: Christian Kamm Date: Thu, 14 Mar 2019 08:12:46 +0000 (+0100) Subject: FolderWizard: Don't crash when typing invalid drive #7041 X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~245 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=021f994584637be20fbad99284917f3aa47ab27d;p=nextcloud-desktop.git FolderWizard: Don't crash when typing invalid drive #7041 When the user typed "x:" where the drive x didn't exist, the validation function would loop forever. Now it shows a "path doesn't exist" error. --- diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 3991ca4b4..180cebbd9 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -1459,7 +1459,10 @@ static QString checkPathValidityRecursive(const QString &path) QFileInfo selFile(path); if (!selFile.exists()) { - return checkPathValidityRecursive(selFile.dir().path()); + QString parentPath = selFile.dir().path(); + if (parentPath != path) + return checkPathValidityRecursive(parentPath); + return FolderMan::tr("The selected path does not exist!"); } if (!selFile.isDir()) { diff --git a/test/testfolderman.cpp b/test/testfolderman.cpp index 89dfe3534..21a475327 100644 --- a/test/testfolderman.cpp +++ b/test/testfolderman.cpp @@ -124,6 +124,19 @@ private slots: QVERIFY(!folderman->checkPathValidityForNewFolder("/usr/bin/somefolder").isNull()); #endif +#ifdef Q_OS_WIN // drive-letter tests + if (!QFileInfo("v:/").exists()) { + QVERIFY(!folderman->checkPathValidityForNewFolder("v:").isNull()); + QVERIFY(!folderman->checkPathValidityForNewFolder("v:/").isNull()); + QVERIFY(!folderman->checkPathValidityForNewFolder("v:/foo").isNull()); + } + if (QFileInfo("c:/").isWritable()) { + QVERIFY(folderman->checkPathValidityForNewFolder("c:").isNull()); + QVERIFY(folderman->checkPathValidityForNewFolder("c:/").isNull()); + QVERIFY(folderman->checkPathValidityForNewFolder("c:/foo").isNull()); + } +#endif + // Invalid paths QVERIFY(!folderman->checkPathValidityForNewFolder("").isNull());