mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-12-05 08:12:35 -08:00
Add warning for leading/trailing spaces in password
This commit is contained in:
1 parent
469ab761ee
commit
1eee1e4ea0
1 file changed
+17
-1
@@ -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());
|
||||
|
||||
|
||||
Reference in new issue
Block a user