From 842e5ba5e009f3e722f2f1efaf1298cbe6d8930e Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Thu, 26 Feb 2015 09:40:54 +0100 Subject: [PATCH] Sharing: Fix for folders containing &. #2892 --- shell_integration/nautilus/syncstate.py | 8 +++++--- src/gui/sharedialog.cpp | 14 ++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/shell_integration/nautilus/syncstate.py b/shell_integration/nautilus/syncstate.py index 6e1b8ae11..0b5e37dff 100755 --- a/shell_integration/nautilus/syncstate.py +++ b/shell_integration/nautilus/syncstate.py @@ -21,8 +21,10 @@ from gi.repository import GObject, Nautilus # do not touch the following line. appname = 'ownCloud' -def get_local_path(path): - return path.replace("file://", "") +def get_local_path(url): + if url[0:7] == 'file://': + url = url[7:] + return urllib.unquote(url) def get_runtime_dir(): """Returns the value of $XDG_RUNTIME_DIR, a directory path. @@ -254,7 +256,7 @@ class SyncStateExtension(GObject.GObject, Nautilus.ColumnProvider, Nautilus.Info if item.get_uri_scheme() != 'file': return - filename = urllib.unquote(item.get_uri()[7:]) + filename = get_local_path(item.get_uri()) if item.is_directory(): filename += '/' diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp index be620cb3d..b81338d52 100644 --- a/src/gui/sharedialog.cpp +++ b/src/gui/sharedialog.cpp @@ -603,13 +603,19 @@ void OcsShareJob::start() QNetworkRequest req; req.setRawHeader("OCS-APIREQUEST", "true"); req.setRawHeader("Content-Type", "application/x-www-form-urlencoded"); - QBuffer *buffer = new QBuffer; - QStringList tmp; + // Url encode the _postParams and put them in a buffer. + QByteArray postData; Q_FOREACH(auto tmp2, _postParams) { - tmp.append(tmp2.first + "=" + tmp2.second); + if (! postData.isEmpty()) { + postData.append("&"); + } + postData.append(QUrl::toPercentEncoding(tmp2.first)); + postData.append("="); + postData.append(QUrl::toPercentEncoding(tmp2.second)); } - buffer->setData(tmp.join("&").toAscii()); + QBuffer *buffer = new QBuffer; + buffer->setData(postData); auto queryItems = _url.queryItems(); queryItems.append(qMakePair(QString::fromLatin1("format"), QString::fromLatin1("json")));