Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair E2EE on sync folders which don't point to the root of the server on the remote end #2892

Merged
merged 2 commits into from
Feb 4, 2021
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/abstractpropagateremotedeleteencrypted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void AbstractPropagateRemoteDeleteEncrypted::storeFirstErrorString(const QString
void AbstractPropagateRemoteDeleteEncrypted::startLsColJob(const QString &path)
{
qCDebug(ABSTRACT_PROPAGATE_REMOVE_ENCRYPTED) << "Folder is encrypted, let's get the Id from it.";
auto job = new LsColJob(_propagator->account(), path, this);
auto job = new LsColJob(_propagator->account(), _propagator->fullRemotePath(path), this);
job->setProperties({"resourcetype", "http://owncloud.org/ns:fileid"});
connect(job, &LsColJob::directoryListingSubfolders, this, &AbstractPropagateRemoteDeleteEncrypted::slotFolderEncryptedIdReceived);
connect(job, &LsColJob::finishedWithError, this, &AbstractPropagateRemoteDeleteEncrypted::taskFailed);
Expand Down
21 changes: 19 additions & 2 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ void ProcessDirectoryJob::process()

// On the server the path is mangled in case of E2EE
if (!e.serverEntry.e2eMangledName.isEmpty()) {
path._server = e.serverEntry.e2eMangledName;
Q_ASSERT(_discoveryData->_remoteFolder.startsWith('/'));
Q_ASSERT(_discoveryData->_remoteFolder.endsWith('/'));

const auto rootPath = _discoveryData->_remoteFolder.mid(1);
Q_ASSERT(e.serverEntry.e2eMangledName.startsWith(rootPath));

path._server = e.serverEntry.e2eMangledName.mid(rootPath.length());
}

// If the filename starts with a . we consider it a hidden file
Expand Down Expand Up @@ -398,8 +404,19 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo(
item->_etag = serverEntry.etag;
item->_directDownloadUrl = serverEntry.directDownloadUrl;
item->_directDownloadCookies = serverEntry.directDownloadCookies;
item->_encryptedFileName = serverEntry.e2eMangledName;
item->_isEncrypted = serverEntry.isE2eEncrypted;
item->_encryptedFileName = [=] {
if (serverEntry.e2eMangledName.isEmpty()) {
return QString();
}

Q_ASSERT(_discoveryData->_remoteFolder.startsWith('/'));
Q_ASSERT(_discoveryData->_remoteFolder.endsWith('/'));

const auto rootPath = _discoveryData->_remoteFolder.mid(1);
Q_ASSERT(serverEntry.e2eMangledName.startsWith(rootPath));
return serverEntry.e2eMangledName.mid(rootPath.length());
}();

// Check for missing server data
{
Expand Down