Escape msi and owncloud.exe path (who knows...)
authorDominik Schmidt <dev@dominik-schmidt.de>
Wed, 13 Jun 2018 20:23:21 +0000 (22:23 +0200)
committerCamila (Rebase PR Action) <hello@camila.codes>
Tue, 24 Nov 2020 18:22:33 +0000 (18:22 +0000)
src/gui/updater/ocupdater.cpp

index c88eb0cca15f94ac16b30cb43a802dbee9592349..dcfcaefd4c1b2e0efcca38ba3c3d79cf0a9914f1 100644 (file)
@@ -202,9 +202,15 @@ void OCUpdater::slotStartInstaller()
         // manually here. We wrap the msiexec and client invocation in a powershell
         // script because owncloud.exe will be shut down for installation.
         // | Out-Null forces powershell to wait for msiexec to finish.
-        QString command = QString("&{msiexec /norestart /passive /i '%1' | Out-Null ; &'%2'}")
-            .arg(QDir::toNativeSeparators(updateFile))
-            .arg(QDir::toNativeSeparators(QCoreApplication::applicationFilePath()));
+        auto preparePathForPowershell = [](QString path) {
+            path.replace("'", "''");
+
+            return QDir::toNativeSeparators(path);
+        };
+
+        QString command = QString("&{msiexec /norestart /passive /i '%1'| Out-Null ; &'%2'}")
+            .arg(preparePathForPowershell(updateFile))
+            .arg(preparePathForPowershell(QCoreApplication::applicationFilePath()));
 
         QProcess::startDetached("powershell.exe", QStringList{"-Command", command});
     }