From f1cf697547a5b5d26aee4624e70526647d65eb22 Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Sun, 25 Feb 2018 20:17:43 +0100 Subject: [PATCH] Strip newlines from title, username and URL when saving entries, resolves #1502 --- src/gui/entry/EditEntryWidget.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index b180c2a01..3b70e4453 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -772,12 +772,14 @@ void EditEntryWidget::acceptEntry() void EditEntryWidget::updateEntryData(Entry* entry) const { + QRegularExpression newLineRegex("(?:\r?\n|\r)"); + entry->attributes()->copyCustomKeysFrom(m_entryAttributes); entry->attachments()->copyDataFrom(m_advancedUi->attachmentsWidget->entryAttachments()); entry->customData()->copyDataFrom(m_editWidgetProperties->customData()); - entry->setTitle(m_mainUi->titleEdit->text()); - entry->setUsername(m_mainUi->usernameEdit->text()); - entry->setUrl(m_mainUi->urlEdit->text()); + entry->setTitle(m_mainUi->titleEdit->text().replace(newLineRegex, " ")); + entry->setUsername(m_mainUi->usernameEdit->text().replace(newLineRegex, " ")); + entry->setUrl(m_mainUi->urlEdit->text().replace(newLineRegex, " ")); entry->setPassword(m_mainUi->passwordEdit->text()); entry->setExpires(m_mainUi->expireCheck->isChecked()); entry->setExpiryTime(m_mainUi->expireDatePicker->dateTime().toUTC());