Resolve reference in entry field, prevent recorsive loop, fix EditEntry association bug

This commit is contained in:
thez3ro 2018-02-15 00:21:07 +01:00 committed by Janek Bevendorff
parent 536db062f4
commit c5dd64d18a
2 changed files with 25 additions and 7 deletions

View File

@ -778,17 +778,30 @@ QString Entry::resolvePlaceholderRecursive(const QString& placeholder, int maxDe
case PlaceholderType::Unknown: case PlaceholderType::Unknown:
return placeholder; return placeholder;
case PlaceholderType::Title: case PlaceholderType::Title:
if (placeholderType(title()) == PlaceholderType::Title) {
return title(); return title();
}
return resolvePlaceholderRecursive(title(), maxDepth - 1);
case PlaceholderType::UserName: case PlaceholderType::UserName:
if (placeholderType(username()) == PlaceholderType::UserName) {
return username(); return username();
}
return resolvePlaceholderRecursive(username(), maxDepth - 1);
case PlaceholderType::Password: case PlaceholderType::Password:
if (placeholderType(password()) == PlaceholderType::Password) {
return password(); return password();
}
return resolvePlaceholderRecursive(password(), maxDepth - 1);
case PlaceholderType::Notes: case PlaceholderType::Notes:
if (placeholderType(notes()) == PlaceholderType::Notes) {
return notes(); return notes();
case PlaceholderType::Totp: }
return totp(); return resolvePlaceholderRecursive(notes(), maxDepth - 1);
case PlaceholderType::Url: case PlaceholderType::Url:
if (placeholderType(url()) == PlaceholderType::Url) {
return url(); return url();
}
return resolvePlaceholderRecursive(url(), maxDepth - 1);
case PlaceholderType::UrlWithoutScheme: case PlaceholderType::UrlWithoutScheme:
case PlaceholderType::UrlScheme: case PlaceholderType::UrlScheme:
case PlaceholderType::UrlHost: case PlaceholderType::UrlHost:
@ -802,6 +815,9 @@ QString Entry::resolvePlaceholderRecursive(const QString& placeholder, int maxDe
const QString strUrl = resolveMultiplePlaceholdersRecursive(url(), maxDepth - 1); const QString strUrl = resolveMultiplePlaceholdersRecursive(url(), maxDepth - 1);
return resolveUrlPlaceholder(strUrl, typeOfPlaceholder); return resolveUrlPlaceholder(strUrl, typeOfPlaceholder);
} }
case PlaceholderType::Totp:
// totp can't have placeholder inside
return totp();
case PlaceholderType::CustomAttribute: { case PlaceholderType::CustomAttribute: {
const QString key = placeholder.mid(3, placeholder.length() - 4); // {S:attr} => mid(3, len - 4) const QString key = placeholder.mid(3, placeholder.length() - 4); // {S:attr} => mid(3, len - 4)
return attributes()->hasKey(key) ? attributes()->value(key) : QString(); return attributes()->hasKey(key) ? attributes()->value(key) : QString();

View File

@ -188,6 +188,8 @@ void EditEntryWidget::setupAutoType()
connect(m_autoTypeAssocModel, SIGNAL(modelReset()), SLOT(clearCurrentAssoc())); connect(m_autoTypeAssocModel, SIGNAL(modelReset()), SLOT(clearCurrentAssoc()));
connect(m_autoTypeUi->windowTitleCombo, SIGNAL(editTextChanged(QString)), connect(m_autoTypeUi->windowTitleCombo, SIGNAL(editTextChanged(QString)),
SLOT(applyCurrentAssoc())); SLOT(applyCurrentAssoc()));
connect(m_autoTypeUi->customWindowSequenceButton, SIGNAL(toggled(bool)),
SLOT(applyCurrentAssoc()));
connect(m_autoTypeUi->windowSequenceEdit, SIGNAL(textChanged(QString)), connect(m_autoTypeUi->windowSequenceEdit, SIGNAL(textChanged(QString)),
SLOT(applyCurrentAssoc())); SLOT(applyCurrentAssoc()));
} }