From cce7ad437de40a77b10ad4047f767a95f6bcc2b9 Mon Sep 17 00:00:00 2001 From: Litschi21 Date: Mon, 28 Sep 2026 20:34:29 +0200 Subject: [PATCH 1/2] Add warning for leading/trailing spaces in password --- src/gui/entry/EditEntryWidget.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index e98c05fce3..dc6abf0f0e 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -1334,13 +1334,29 @@ void EditEntryWidget::updateEntryData(Entry* entry) const { QRegularExpression newLineRegex("(?:\r?\n|\r)"); + auto password = m_mainUi->passwordEdit->text(); + if (isModified() && (password.front() == ' ' || password.back() == ' ')) { + QMessageBox spacesMessageBox; + spacesMessageBox.setWindowTitle("Warning: Leading/Trailing Spaces in Password"); + spacesMessageBox.setText("There are leading and/or trailing spaces in your password, would you like to remove them?"); + + auto remove = spacesMessageBox.addButton("Yes", QMessageBox::AcceptRole); + spacesMessageBox.addButton("No", QMessageBox::RejectRole); + + spacesMessageBox.exec(); + if (spacesMessageBox.clickedButton() == remove) { + password = password.trimmed(); + m_mainUi->passwordEdit->setText(password); + } + } + entry->attributes()->copyCustomKeysFrom(m_entryAttributes); entry->attachments()->copyDataFrom(m_attachments.data()); entry->customData()->copyDataFrom(m_customData.data()); entry->setTitle(m_mainUi->titleEdit->text().replace(newLineRegex, " ")); entry->setUsername(m_mainUi->usernameComboBox->lineEdit()->text().replace(newLineRegex, " ")); entry->setUrl(m_mainUi->urlEdit->text().replace(newLineRegex, " ")); - entry->setPassword(m_mainUi->passwordEdit->text()); + entry->setPassword(password); entry->setExpires(m_mainUi->expireCheck->isChecked()); entry->setExpiryTime(m_mainUi->expireDatePicker->dateTime().toUTC()); From fba18a3f02be5c4d0b165a93c50c785401f3b2b6 Mon Sep 17 00:00:00 2001 From: Litschi21 Date: Tue, 29 Sep 2026 15:37:10 +0200 Subject: [PATCH 2/2] Switch to MessageBox instead of QMessageBox --- src/gui/entry/EditEntryWidget.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index dc6abf0f0e..2c47150310 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -1336,15 +1336,11 @@ void EditEntryWidget::updateEntryData(Entry* entry) const auto password = m_mainUi->passwordEdit->text(); if (isModified() && (password.front() == ' ' || password.back() == ' ')) { - QMessageBox spacesMessageBox; - spacesMessageBox.setWindowTitle("Warning: Leading/Trailing Spaces in Password"); - spacesMessageBox.setText("There are leading and/or trailing spaces in your password, would you like to remove them?"); + auto spacesMessageBox = MessageBox::question(nullptr, "Warning: Leading/Trailing Spaces in Password", + "There are leading and/or trailing spaces in your password, would you like to remove them?", + MessageBox::Remove | MessageBox::Cancel, MessageBox::Remove); - auto remove = spacesMessageBox.addButton("Yes", QMessageBox::AcceptRole); - spacesMessageBox.addButton("No", QMessageBox::RejectRole); - - spacesMessageBox.exec(); - if (spacesMessageBox.clickedButton() == remove) { + if (spacesMessageBox == MessageBox::Remove) { password = password.trimmed(); m_mainUi->passwordEdit->setText(password); }