From c5dd64d18a59d6d6cd93627fda4df2d62ca868d4 Mon Sep 17 00:00:00 2001 From: thez3ro Date: Thu, 15 Feb 2018 00:21:07 +0100 Subject: [PATCH] Resolve reference in entry field, prevent recorsive loop, fix EditEntry association bug --- src/core/Entry.cpp | 30 +++++++++++++++++++++++------- src/gui/entry/EditEntryWidget.cpp | 2 ++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index 8db955c93..a245d7027 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -778,17 +778,30 @@ QString Entry::resolvePlaceholderRecursive(const QString& placeholder, int maxDe case PlaceholderType::Unknown: return placeholder; case PlaceholderType::Title: - return title(); + if (placeholderType(title()) == PlaceholderType::Title) { + return title(); + } + return resolvePlaceholderRecursive(title(), maxDepth - 1); case PlaceholderType::UserName: - return username(); + if (placeholderType(username()) == PlaceholderType::UserName) { + return username(); + } + return resolvePlaceholderRecursive(username(), maxDepth - 1); case PlaceholderType::Password: - return password(); + if (placeholderType(password()) == PlaceholderType::Password) { + return password(); + } + return resolvePlaceholderRecursive(password(), maxDepth - 1); case PlaceholderType::Notes: - return notes(); - case PlaceholderType::Totp: - return totp(); + if (placeholderType(notes()) == PlaceholderType::Notes) { + return notes(); + } + return resolvePlaceholderRecursive(notes(), maxDepth - 1); case PlaceholderType::Url: - return url(); + if (placeholderType(url()) == PlaceholderType::Url) { + return url(); + } + return resolvePlaceholderRecursive(url(), maxDepth - 1); case PlaceholderType::UrlWithoutScheme: case PlaceholderType::UrlScheme: case PlaceholderType::UrlHost: @@ -802,6 +815,9 @@ QString Entry::resolvePlaceholderRecursive(const QString& placeholder, int maxDe const QString strUrl = resolveMultiplePlaceholdersRecursive(url(), maxDepth - 1); return resolveUrlPlaceholder(strUrl, typeOfPlaceholder); } + case PlaceholderType::Totp: + // totp can't have placeholder inside + return totp(); case PlaceholderType::CustomAttribute: { const QString key = placeholder.mid(3, placeholder.length() - 4); // {S:attr} => mid(3, len - 4) return attributes()->hasKey(key) ? attributes()->value(key) : QString(); diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index bab5a0728..ab2a85f81 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -188,6 +188,8 @@ void EditEntryWidget::setupAutoType() connect(m_autoTypeAssocModel, SIGNAL(modelReset()), SLOT(clearCurrentAssoc())); connect(m_autoTypeUi->windowTitleCombo, SIGNAL(editTextChanged(QString)), SLOT(applyCurrentAssoc())); + connect(m_autoTypeUi->customWindowSequenceButton, SIGNAL(toggled(bool)), + SLOT(applyCurrentAssoc())); connect(m_autoTypeUi->windowSequenceEdit, SIGNAL(textChanged(QString)), SLOT(applyCurrentAssoc())); }