From d12f15da92a31fa5942f4f2560fa85f9dad970d0 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Sun, 30 Jun 2019 15:04:43 -0400 Subject: [PATCH] Add warning prior to export of database * Ensures user is aware that the exported data is unencrypted and vulnerable --- src/gui/DatabaseTabWidget.cpp | 20 ++++++++++++++++++++ src/gui/DatabaseTabWidget.h | 1 + 2 files changed, 21 insertions(+) diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index 84e80e2b..a56008c7 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -390,6 +390,10 @@ void DatabaseTabWidget::exportToCsv() return; } + if (!warnOnExport()) { + return; + } + QString fileName = fileDialog()->getSaveFileName( this, tr("Export database to CSV file"), QString(), tr("CSV file").append(" (*.csv)"), nullptr, nullptr, "csv"); if (fileName.isEmpty()) { @@ -411,6 +415,10 @@ void DatabaseTabWidget::exportToHtml() return; } + if (!warnOnExport()) { + return; + } + QString fileName = fileDialog()->getSaveFileName(this, tr("Export database to HTML file"), QString(), @@ -429,6 +437,18 @@ void DatabaseTabWidget::exportToHtml() } } +bool DatabaseTabWidget::warnOnExport() +{ + auto ans = + MessageBox::question(this, + tr("Export Confirmation"), + tr("You are about to export your database to an unencrypted file. This will leave your " + "passwords and sensitive information vulnerable! Are you sure you want to continue?"), + MessageBox::Yes | MessageBox::No, + MessageBox::No); + return ans == MessageBox::Yes; +} + void DatabaseTabWidget::changeMasterKey() { currentDatabaseWidget()->switchToMasterKeyChange(); diff --git a/src/gui/DatabaseTabWidget.h b/src/gui/DatabaseTabWidget.h index 517d9f4e..87e9bbf7 100644 --- a/src/gui/DatabaseTabWidget.h +++ b/src/gui/DatabaseTabWidget.h @@ -99,6 +99,7 @@ private slots: private: QSharedPointer execNewDatabaseWizard(); void updateLastDatabases(const QString& filename); + bool warnOnExport(); QPointer m_dbWidgetStateSync; QPointer m_dbWidgetPendingLock;