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:
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();

View File

@ -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()));
}