mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 21:15:55 +03:00
This commit is contained in:
parent
aefbca0787
commit
bc4753e938
1 changed files with 19 additions and 4 deletions
|
@ -47,6 +47,19 @@ void OcsJob::appendPath(const QString &id)
|
|||
setPath(path() + QLatin1Char('/') + id);
|
||||
}
|
||||
|
||||
static QList<QPair<QByteArray, QByteArray>>
|
||||
percentEncodeQueryItems(
|
||||
const QList<QPair<QString, QString>> & items)
|
||||
{
|
||||
QList<QPair<QByteArray, QByteArray>> result;
|
||||
foreach (const auto& item, items) {
|
||||
result.append(qMakePair(
|
||||
QUrl::toPercentEncoding(item.first),
|
||||
QUrl::toPercentEncoding(item.second)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void OcsJob::start()
|
||||
{
|
||||
QNetworkRequest req;
|
||||
|
@ -57,7 +70,9 @@ void OcsJob::start()
|
|||
QBuffer *buffer = new QBuffer;
|
||||
|
||||
if (_verb == "GET") {
|
||||
url.setQueryItems(_params);
|
||||
// Note: QUrl::setQueryItems() does not fully percent encode
|
||||
// the query items, see #5042
|
||||
url.setEncodedQueryItems(percentEncodeQueryItems(_params));
|
||||
} else if (_verb == "POST" || _verb == "PUT") {
|
||||
// Url encode the _postParams and put them in a buffer.
|
||||
QByteArray postData;
|
||||
|
@ -73,9 +88,9 @@ void OcsJob::start()
|
|||
}
|
||||
|
||||
//We want json data
|
||||
auto queryItems = url.queryItems();
|
||||
queryItems.append(qMakePair(QString::fromLatin1("format"), QString::fromLatin1("json")));
|
||||
url.setQueryItems(queryItems);
|
||||
auto queryItems = url.encodedQueryItems();
|
||||
queryItems.append(qMakePair(QByteArray("format"), QByteArray("json")));
|
||||
url.setEncodedQueryItems(queryItems);
|
||||
|
||||
setReply(davRequest(_verb, url, req, buffer));
|
||||
setupConnections(reply());
|
||||
|
|
Loading…
Reference in a new issue