From 8b8fb9562f3b660d29ea221b892f26a583802414 Mon Sep 17 00:00:00 2001 From: Guillaume Turchini <orion+github@orion78.fr> Date: Mon, 1 Mar 2021 03:18:53 +0100 Subject: [PATCH] Allow CSV import of bare TOTP secrets Fixes #6167 --- src/gui/csvImport/CsvImportWidget.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/csvImport/CsvImportWidget.cpp b/src/gui/csvImport/CsvImportWidget.cpp index e78e9f94a..809fc6e53 100644 --- a/src/gui/csvImport/CsvImportWidget.cpp +++ b/src/gui/csvImport/CsvImportWidget.cpp @@ -208,8 +208,13 @@ void CsvImportWidget::writeDatabase() entry->setUrl(m_parserModel->data(m_parserModel->index(r, 4)).toString()); entry->setNotes(m_parserModel->data(m_parserModel->index(r, 5)).toString()); - if (m_parserModel->data(m_parserModel->index(r, 6)).isValid()) { - auto totp = Totp::parseSettings(m_parserModel->data(m_parserModel->index(r, 6)).toString()); + auto otpString = m_parserModel->data(m_parserModel->index(r, 6)); + if (otpString.isValid() && !otpString.toString().isEmpty()) { + auto totp = Totp::parseSettings(otpString.toString()); + if (totp->key.isEmpty()) { + // Bare secret, use default TOTP settings + totp = Totp::parseSettings({}, otpString.toString()); + } entry->setTotp(totp); }