From 10170a555e0200640dfc7577db05811b7f4388b8 Mon Sep 17 00:00:00 2001 From: thez3ro Date: Mon, 5 Mar 2018 23:32:04 +0100 Subject: [PATCH] add test case for recursive placeholders --- src/core/Entry.cpp | 2 +- tests/TestEntry.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index 1aa79c634..25ef6b50e 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -796,7 +796,7 @@ QString Entry::resolvePlaceholderRecursive(const QString& placeholder, int maxDe switch (typeOfPlaceholder) { case PlaceholderType::NotPlaceholder: case PlaceholderType::Unknown: - return placeholder; + return resolveMultiplePlaceholdersRecursive(placeholder, maxDepth - 1); case PlaceholderType::Title: if (placeholderType(title()) == PlaceholderType::Title) { return title(); diff --git a/tests/TestEntry.cpp b/tests/TestEntry.cpp index 94100c0a6..c088fc01f 100644 --- a/tests/TestEntry.cpp +++ b/tests/TestEntry.cpp @@ -279,6 +279,17 @@ void TestEntry::testResolveRecursivePlaceholders() QCOMPARE(entry6->resolvePlaceholder(entry6->title()), QString("Entry2Title")); QCOMPARE(entry6->resolvePlaceholder(entry6->username()), QString("Entry2Title")); QCOMPARE(entry6->resolvePlaceholder(entry6->password()), QString("{PASSWORD}")); + + auto* entry7 = new Entry(); + entry7->setGroup(root); + entry7->setUuid(Uuid::random()); + entry7->setTitle(QString("{REF:T@I:%1} and something else").arg(entry3->uuid().toHex())); + entry7->setUsername(QString("{TITLE}")); + entry7->setPassword(QString("PASSWORD")); + + QCOMPARE(entry7->resolvePlaceholder(entry7->title()), QString("Entry2Title and something else")); + QCOMPARE(entry7->resolvePlaceholder(entry7->username()), QString("Entry2Title and something else")); + QCOMPARE(entry7->resolvePlaceholder(entry7->password()), QString("PASSWORD")); } void TestEntry::testResolveReferencePlaceholders()