[Pkg-owncloud-commits] [owncloud-client] 94/121: Sharing: Fix bug with file names containing percent encodes #5042 (#5043)
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu Jul 28 15:32:02 UTC 2016
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit bc4753e9381d6b948ced34490c98eaee4d9d265e
Author: ckamm <mail at ckamm.de>
Date: Tue Jul 12 14:25:33 2016 +0200
Sharing: Fix bug with file names containing percent encodes #5042 (#5043)
---
src/gui/ocsjob.cpp | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/gui/ocsjob.cpp b/src/gui/ocsjob.cpp
index ff313e4..fb2b1ca 100644
--- a/src/gui/ocsjob.cpp
+++ b/src/gui/ocsjob.cpp
@@ -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());
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list