auto writeFileResponse = [&](const FileInfo &fileInfo) {
xml.writeStartElement(davUri, QStringLiteral("response"));
- xml.writeTextElement(davUri, QStringLiteral("href"), prefix + fileInfo.path());
+ xml.writeTextElement(davUri, QStringLiteral("href"), prefix + QUrl::toPercentEncoding(fileInfo.path(), "/"));
xml.writeStartElement(davUri, QStringLiteral("propstat"));
xml.writeStartElement(davUri, QStringLiteral("prop"));
FileInfo *fileInfo = remoteRootFileInfo.find(fileName);
if (fileInfo) {
- Q_ASSERT(request.hasRawHeader("If")); // The client should put this header
- if (request.rawHeader("If") != QByteArray("<" + request.rawHeader("Destination") +
- "> ([\"" + fileInfo->etag.toLatin1() + "\"])")) {
+ // The client should put this header
+ Q_ASSERT(request.hasRawHeader("If"));
+
+ // And it should condition on the destination file
+ auto start = QByteArray("<" + request.rawHeader("Destination") + ">");
+ Q_ASSERT(request.rawHeader("If").startsWith(start));
+
+ if (request.rawHeader("If") != start + " ([\"" + fileInfo->etag.toLatin1() + "\"])") {
return nullptr;
}
fileInfo->size = size;
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(nGET, 0);
}
+
+ void testPercentEncoding() {
+ FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
+ fakeFolder.syncEngine().account()->setCapabilities({ { "dav", QVariantMap{ {"chunking", "1.0"} } } });
+ const int size = 5 * 1000 * 1000;
+ setChunkSize(fakeFolder.syncEngine(), 1 * 1000 * 1000);
+
+ fakeFolder.localModifier().insert("A/file % \u20ac", size);
+ QVERIFY(fakeFolder.syncOnce());
+ QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
+
+ // Only the second upload contains an "If" header
+ fakeFolder.localModifier().appendByte("A/file % \u20ac");
+ QVERIFY(fakeFolder.syncOnce());
+ QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
+ }
};
QTEST_GUILESS_MAIN(TestChunkingNG)