Use addQueryParams for checkTokenForEditLocally SimpleApiJob
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 27 Oct 2022 14:32:51 +0000 (16:32 +0200)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 28 Oct 2022 10:38:46 +0000 (12:38 +0200)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/folderman.cpp

index 46e586b89b1139ae7e7bbc8a9a0185c2071d155a..44bc904d64ff12c4baed01358ffc7d4570793d8e 100644 (file)
@@ -1554,13 +1554,14 @@ void FolderMan::editFileLocally(const QString &userId, const QString &relPath, c
         return;
     }
 
-    // Sanitise the token
-    const auto encodedToken = QString::fromUtf8(QUrl::toPercentEncoding(token));
-    // Sanitise the relPath
-    const auto encodedRelPath = QUrl::toPercentEncoding(relPath);
+    const auto encodedToken = QString::fromUtf8(QUrl::toPercentEncoding(token));   // Sanitise the token
+    const auto encodedRelPath = QUrl::toPercentEncoding(slashPrefixedPath); // Sanitise the relPath
     const auto checkTokenForEditLocally = new SimpleApiJob(accountFound->account(), QStringLiteral("/ocs/v2.php/apps/files/api/v1/openlocaleditor/%1").arg(encodedToken));
+
+    QUrlQuery params;
+    params.addQueryItem(QStringLiteral("path"), slashPrefixedPath);
+    checkTokenForEditLocally->addQueryParams(params);
     checkTokenForEditLocally->setVerb(SimpleApiJob::Verb::Post);
-    checkTokenForEditLocally->setBody(QByteArray{"path=/"}.append(encodedRelPath));
     connect(checkTokenForEditLocally, &SimpleApiJob::resultReceived, checkTokenForEditLocally, [this, folderForFile, localFilePath, showError, accountFound, relPath] (int statusCode) {
         constexpr auto HTTP_OK_CODE = 200;
         if (statusCode != HTTP_OK_CODE) {