Sharing: Fix for folders containing &. #2892

This commit is contained in:
Christian Kamm 2015-02-26 09:40:54 +01:00
parent 10d28292c6
commit 842e5ba5e0
2 changed files with 15 additions and 7 deletions

View file

@ -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 += '/'

View file

@ -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")));