Skip to content

Commit

Permalink
Make the limitation that only advanced string fields starting with "K…
Browse files Browse the repository at this point in the history
…PH: " optional
  • Loading branch information
berrnd committed Sep 16, 2015
1 parent 3a29380 commit 73306a1
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 43 deletions.
Binary file modified KeePassHttp.plgx
Binary file not shown.
7 changes: 7 additions & 0 deletions KeePassHttp/ConfigOpt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class ConfigOpt
const string SearchInAllOpenedDatabasesKey = "KeePassHttp_SearchInAllOpenedDatabases";
const string MatchSchemesKey = "KeePassHttp_MatchSchemes";
const string ReturnStringFieldsKey = "KeePassHttp_ReturnStringFields";
const string ReturnStringFieldsWithKphOnlyKey = "KeePassHttp_ReturnStringFieldsWithKphOnly";
const string SortResultByUsernameKey = "KeePassHttp_SortResultByUsername";
const string ListenerPortKey = "KeePassHttp_ListenerPort";
const string ListenerHostKey = "KeePassHttp_ListenerHost";
Expand Down Expand Up @@ -70,6 +71,12 @@ public bool ReturnStringFields
set { _config.SetBool(ReturnStringFieldsKey, value); }
}

public bool ReturnStringFieldsWithKphOnly
{
get { return _config.GetBool(ReturnStringFieldsWithKphOnlyKey, true); }
set { _config.SetBool(ReturnStringFieldsWithKphOnlyKey, value); }
}

public bool SortResultByUsername
{
get { return _config.GetBool(SortResultByUsernameKey, true); }
Expand Down
13 changes: 10 additions & 3 deletions KeePassHttp/Handlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,17 @@ private ResponseEntry PrepareElementForResponseEntries(ConfigOpt configOpt, PwEn
fields = new List<ResponseStringField>();
foreach (var sf in entryDatabase.entry.Strings)
{
if (sf.Key.StartsWith("KPH: "))
var sfValue = entryDatabase.entry.Strings.ReadSafe(sf.Key);
if (configOpt.ReturnStringFieldsWithKphOnly)
{
var sfValue = entryDatabase.entry.Strings.ReadSafe(sf.Key);
fields.Add(new ResponseStringField(sf.Key.Substring(5), sfValue));
if (sf.Key.StartsWith("KPH: "))
{
fields.Add(new ResponseStringField(sf.Key.Substring(5), sfValue));
}
}
else
{
fields.Add(new ResponseStringField(sf.Key, sfValue));
}
}

Expand Down
82 changes: 49 additions & 33 deletions KeePassHttp/OptionsForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions KeePassHttp/OptionsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ private void OptionsForm_Load(object sender, EventArgs e)
credSearchInAllOpenedDatabases.Checked = _config.SearchInAllOpenedDatabases;
matchSchemesCheckbox.Checked = _config.MatchSchemes;
returnStringFieldsCheckbox.Checked = _config.ReturnStringFields;
returnStringFieldsWithKphOnlyCheckBox.Checked = _config.ReturnStringFieldsWithKphOnly;
SortByUsernameRadioButton.Checked = _config.SortResultByUsername;
SortByTitleRadioButton.Checked = !_config.SortResultByUsername;
portNumber.Value = _config.ListenerPort;
hostName.Text = _config.ListenerHost;

this.returnStringFieldsCheckbox_CheckedChanged(null, EventArgs.Empty);
}

private void okButton_Click(object sender, EventArgs e)
Expand All @@ -59,6 +62,7 @@ private void okButton_Click(object sender, EventArgs e)
_config.SearchInAllOpenedDatabases = credSearchInAllOpenedDatabases.Checked;
_config.MatchSchemes = matchSchemesCheckbox.Checked;
_config.ReturnStringFields = returnStringFieldsCheckbox.Checked;
_config.ReturnStringFieldsWithKphOnly = returnStringFieldsWithKphOnlyCheckBox.Checked;
_config.SortResultByUsername = SortByUsernameRadioButton.Checked;
_config.ListenerPort = (int)portNumber.Value;
_config.ListenerHost = hostName.Text;
Expand Down Expand Up @@ -212,5 +216,10 @@ private void SetRestartRequired()
{
_restartRequired = (_config.ListenerPort != portNumber.Value) || (_config.ListenerHost != hostName.Text);
}

private void returnStringFieldsCheckbox_CheckedChanged(object sender, EventArgs e)
{
this.returnStringFieldsWithKphOnlyCheckBox.Enabled = this.returnStringFieldsCheckbox.Checked;
}
}
}
7 changes: 0 additions & 7 deletions KeePassHttp/OptionsForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="label3.Text" xml:space="preserve">
<value>If there are more fields needed than username + password,
normal "String Fields" are used, which can be defined in the
"Advanced" tab of an entry.
String fields are returned in alphabetical order and have to start
with "KPH: " (mind the space after KPH:).</value>
</data>
</root>

3 comments on commit 73306a1

@HolySephi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly happened here? The filesize of the compiled file KeePassHttp.plgx doubled without a version number increase and was pushed by a user without any other (accepted) pull-requests? I might be paranoid but maybe a lead developer might want look into this or give me a quick hint about what i am missing.

@pfn
Copy link
Owner

@pfn pfn commented on 73306a1 Mar 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's usually a mistake of the build process (objects get included if not cleaned first). And I made a mistake of merging this pr when it included a binary change. Will revert the binary change later.

@HolySephi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i guessed something like that but would prefer an "official built" file from you over this external built file. Thanks for the explanation.

Please sign in to comment.