From: Ivan Čukić Date: Thu, 28 May 2020 18:23:55 +0000 (+0200) Subject: Show a broken lock icon for unencrypted subdirectory X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~222^2^2~191^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c800d9149eea045fe30ddff186bb2d00fae6712c;p=nextcloud-desktop.git Show a broken lock icon for unencrypted subdirectory The E2E application allows creating unencrypted subdirectories in an encrypted parent. This is a big privacy problem. This patch shows a red broken lock icon for these subdirectories in the NC client UI. Signed-off-by: Ivan Čukić --- diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 350e5c308..52370bfa5 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -158,6 +158,8 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const case Qt::DecorationRole: if (_accountState->account()->e2e()->isFolderEncrypted(x._path)) { return QIcon(QLatin1String(":/client/theme/lock-https.svg")); + } else if (_accountState->account()->e2e()->isAnyParentFolderEncrypted(x._path)) { + return QIcon(QLatin1String(":/client/theme/lock-broken.svg")); } return QFileIconProvider().icon(x._isExternal ? QFileIconProvider::Network : QFileIconProvider::Folder); case Qt::ForegroundRole: diff --git a/src/libsync/clientsideencryption.cpp b/src/libsync/clientsideencryption.cpp index 83f6cbb03..6401a2269 100644 --- a/src/libsync/clientsideencryption.cpp +++ b/src/libsync/clientsideencryption.cpp @@ -1482,6 +1482,22 @@ bool ClientSideEncryption::isFolderEncrypted(const QString& path) const { return (*it); } +bool ClientSideEncryption::isAnyParentFolderEncrypted(const QString &path) const +{ + int slashPosition = 0; + + while ((slashPosition = path.indexOf("/", slashPosition + 1)) != -1) { + // Ignore the last slash + if (slashPosition == path.length() - 1) break; + + if (isFolderEncrypted(path.left(slashPosition + 1))) { + return true; + } + } + + return false; +} + bool EncryptionHelper::fileEncryption(const QByteArray &key, const QByteArray &iv, QFile *input, QFile *output, QByteArray& returnTag) { if (!input->open(QIODevice::ReadOnly)) { diff --git a/src/libsync/clientsideencryption.h b/src/libsync/clientsideencryption.h index 05425a26f..0c92ffa1c 100644 --- a/src/libsync/clientsideencryption.h +++ b/src/libsync/clientsideencryption.h @@ -83,6 +83,7 @@ public: // to be used together with FolderStatusModel::FolderInfo::_path. bool isFolderEncrypted(const QString& path) const; + bool isAnyParentFolderEncrypted(const QString &path) const; void setFolderEncryptedStatus(const QString& path, bool status); void forgetSensitiveData(); diff --git a/theme.qrc b/theme.qrc index 8ec17e8b3..6adcfdc46 100644 --- a/theme.qrc +++ b/theme.qrc @@ -153,6 +153,7 @@ theme/change.svg theme/lock-http.svg theme/lock-https.svg + theme/lock-broken.svg theme/network.svg theme/account.svg theme/colored/add.svg diff --git a/theme/lock-broken.svg b/theme/lock-broken.svg new file mode 100644 index 000000000..c6cfce606 --- /dev/null +++ b/theme/lock-broken.svg @@ -0,0 +1 @@ +