Add warning for leading/trailing spaces in password

This commit is contained in:
Litschi21 authored and Jonathan White committed 2026-11-28 22:04:24 -05:00
1 parent 469ab761ee
commit 1eee1e4ea0
1 file changed
+17 -1
+17 -1
View File
@@ -1334,13 +1334,29 @@ void EditEntryWidget::updateEntryData(Entry* entry) const
{
QRegularExpression newLineRegex("(?:\r?\n|\r)");
// Check for leading or trailing spaces in the password, ask to remove them if modified this round
auto password = m_mainUi->passwordEdit->text();
auto trimmed_password = password.trimmed();
if (isModified() && password != trimmed_password) {
auto spacesMessageBox = MessageBox::question(
nullptr,
"Remove 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);
if (spacesMessageBox == MessageBox::Remove) {
m_mainUi->passwordEdit->setText(trimmed_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());