Skip to content

Commit b9a6813

Browse files
authored
Merge pull request pfn#325 from Px7-941/master
add follow references for the value before add to ResponseStringField
2 parents c2c4eb5 + 7728a1c commit b9a6813

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

KeePassHttp.plgx

104 Bytes
Binary file not shown.

KeePassHttp/Handlers.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using KeePass;
1919
using KeePassLib.Cryptography.PasswordGenerator;
2020
using KeePassLib.Cryptography;
21+
using KeePass.Util.Spr;
2122

2223
namespace KeePassHttp {
2324
public sealed partial class KeePassHttpExt : Plugin
@@ -477,8 +478,10 @@ private int LevenshteinDistance(string source, string target)
477478

478479
private ResponseEntry PrepareElementForResponseEntries(ConfigOpt configOpt, PwEntryDatabase entryDatabase)
479480
{
481+
SprContext ctx = new SprContext(entryDatabase.entry, entryDatabase.database, SprCompileFlags.All, false, false);
482+
480483
var name = entryDatabase.entry.Strings.ReadSafe(PwDefs.TitleField);
481-
var loginpass = GetUserPass(entryDatabase);
484+
var loginpass = GetUserPass(entryDatabase, ctx);
482485
var login = loginpass[0];
483486
var passwd = loginpass[1];
484487
var uuid = entryDatabase.entry.Uuid.ToHexString();
@@ -490,6 +493,10 @@ private ResponseEntry PrepareElementForResponseEntries(ConfigOpt configOpt, PwEn
490493
foreach (var sf in entryDatabase.entry.Strings)
491494
{
492495
var sfValue = entryDatabase.entry.Strings.ReadSafe(sf.Key);
496+
497+
// follow references
498+
sfValue = SprEngine.Compile(sfValue, ctx);
499+
493500
if (configOpt.ReturnStringFieldsWithKphOnly)
494501
{
495502
if (sf.Key.StartsWith("KPH: "))

KeePassHttp/KeePassHttp.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,13 @@ internal string[] GetUserPass(PwEntryDatabase entryDatabase)
410410
// follow references
411411
SprContext ctx = new SprContext(entryDatabase.entry, entryDatabase.database,
412412
SprCompileFlags.All, false, false);
413+
414+
return GetUserPass(entryDatabase, ctx);
415+
}
416+
417+
internal string[] GetUserPass(PwEntryDatabase entryDatabase, SprContext ctx)
418+
{
419+
// follow references
413420
string user = SprEngine.Compile(
414421
entryDatabase.entry.Strings.ReadSafe(PwDefs.UserNameField), ctx);
415422
string pass = SprEngine.Compile(

mono/KeePassHttp.dll

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)