Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libsync/propagateuploadng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "config.h"

Check failure on line 7 in src/libsync/propagateuploadng.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/propagateuploadng.cpp:7:10 [clang-diagnostic-error]

'config.h' file not found
#include "propagateupload.h"
#include "owncloudpropagator_p.h"
#include "networkjobs.h"
Expand Down Expand Up @@ -82,7 +82,7 @@
const auto davUrl = Utility::trailingSlashPath(propagator()->account()->davUrl().toString());
const auto remotePath = Utility::noLeadingSlashPath(propagator()->fullRemotePath(_fileToUpload._file));
const auto destination = QString(davUrl + remotePath);
return destination.toUtf8();
return QUrl::toPercentEncoding(destination, "/");
}

void PropagateUploadFileNG::doStartUpload()
Expand Down
26 changes: 26 additions & 0 deletions test/testchunkingng.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud GmbH
Expand Down Expand Up @@ -127,6 +127,32 @@
QCOMPARE(fakeFolder.uploadState().children.count(), 2); // the transfer was done with chunking
}

void testDestinationHeaderPercentEncoding()
{
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
fakeFolder.syncEngine().account()->setCapabilities({ { "dav", QVariantMap{ {"chunking", "1.0"} } } });
setChunkSize(fakeFolder.syncEngine(), 1 * 1000 * 1000);

QByteArray destinationHeader;
fakeFolder.setServerOverride([&destinationHeader](QNetworkAccessManager::Operation, const QNetworkRequest &request, QIODevice *) -> QNetworkReply * {
if (destinationHeader.isEmpty() && request.hasRawHeader("Destination")) {
destinationHeader = request.rawHeader("Destination");
}
return nullptr;
});

const QString filePath = QStringLiteral("A/SQ-0.5%BF-150/a0");
const int size = 2 * 1000 * 1000; // 2 MB

fakeFolder.localModifier().mkdir(QStringLiteral("A/SQ-0.5%BF-150"));
fakeFolder.localModifier().insert(filePath, size);
QVERIFY(fakeFolder.syncOnce());
QVERIFY(!destinationHeader.isEmpty());
QVERIFY(destinationHeader.contains("SQ-0.5%25BF-150"));
QVERIFY(destinationHeader.contains("/A/SQ-0.5%25BF-150/"));
QVERIFY(!destinationHeader.contains("%2F"));
}

// Test resuming when there's a confusing chunk added
void testResume1() {
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
Expand Down
Loading