mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Check maxDepth on placeholder resolution to avoid infinite recursion
This commit is contained in:
parent
c5dd64d18a
commit
4c52aa9c88
@ -772,6 +772,11 @@ QString Entry::resolveMultiplePlaceholdersRecursive(const QString& str, int maxD
|
||||
|
||||
QString Entry::resolvePlaceholderRecursive(const QString& placeholder, int maxDepth) const
|
||||
{
|
||||
if (maxDepth <= 0) {
|
||||
qWarning("Maximum depth of replacement has been reached. Entry uuid: %s", qPrintable(uuid().toHex()));
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
const PlaceholderType typeOfPlaceholder = placeholderType(placeholder);
|
||||
switch (typeOfPlaceholder) {
|
||||
case PlaceholderType::NotPlaceholder:
|
||||
@ -831,6 +836,11 @@ QString Entry::resolvePlaceholderRecursive(const QString& placeholder, int maxDe
|
||||
|
||||
QString Entry::resolveReferencePlaceholderRecursive(const QString& placeholder, int maxDepth) const
|
||||
{
|
||||
if (maxDepth <= 0) {
|
||||
qWarning("Maximum depth of replacement has been reached. Entry uuid: %s", qPrintable(uuid().toHex()));
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
// resolving references in format: {REF:<WantedField>@<SearchIn>:<SearchText>}
|
||||
// using format from http://keepass.info/help/base/fieldrefs.html at the time of writing
|
||||
|
||||
@ -844,6 +854,9 @@ QString Entry::resolveReferencePlaceholderRecursive(const QString& placeholder,
|
||||
const QString searchText = match.captured(EntryAttributes::SearchTextGroupName);
|
||||
|
||||
const EntryReferenceType searchInType = Entry::referenceType(searchIn);
|
||||
|
||||
Q_ASSERT(m_group);
|
||||
Q_ASSERT(m_group->database());
|
||||
const Entry* refEntry = m_group->database()->resolveEntry(searchText, searchInType);
|
||||
|
||||
if (refEntry) {
|
||||
|
Loading…
Reference in New Issue
Block a user