Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow references to be part of a field #1649

Merged
merged 1 commit into from
Mar 5, 2018
Merged

Allow references to be part of a field #1649

merged 1 commit into from
Mar 5, 2018

Conversation

salsifis
Copy link
Contributor

@salsifis salsifis commented Mar 5, 2018

Currently, when a field value contains a reference plus other things, then:

  • Auto-type is broken with that field
  • References to this field are not properly resolved

This commit fixes both issues.

Description

When editing database entries, one can use placeholders such as {USERNAME}, {PASSWORD}, {URL:HOST} (these will typically be used in auto-type patterns), but also reference placeholders like {REF:x@y:zzzz}, that indicate to use a value from a given field in a given entry.

The function resolvePlaceholderRecursive, will attempt to replace a placeholder with the final value it points to. It calls itself if the resulting value consists of a placeholder, such as reference to reference is also supported. However when the resulting value contains a placeholder, it fails to replace it because it expects its input to span over a single placeholder.

For example, if an entry contains {USERNAME} in the auto-type pattern, when performing auto-type, resolvePlaceholderRecursive will be called with {USERNAME} as a parameter. After expansion, it can result in something like {REF:U@I:xxxx-…}@baz.com, and the function would call itself again. This time however, the input string would not be recognized as a valid placeholder, and therefore is returned without further expansion.

The fix is to call resolveMultiplePlaceholdersRecursive instead in the recursion step, such that the string is parsed again in order to look for placeholders.

Motivation and context

This change fixes auto-type for entries in which an auto-typed field contains a reference to another entry field. For example a base entry with login information, and a derived entry with more complete login for use in a certain setup, prefixed with domain for example.

How has this been tested?

I only tested that my use case was fixed.

Types of changes

  • ✅ Bug fix (non-breaking change which fixes an issue)

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ✅ My code follows the code style of this project. [REQUIRED]
  • ✅ All new and existing tests passed. [REQUIRED]
  • ✅ I have compiled and verified my code with -DWITH_ASAN=ON. [REQUIRED]
  • ✗ My change requires a change to the documentation and I have updated it accordingly.
  • ✗ I have added tests to cover my changes.

Post-scriptum

Sorry for the initial, non-conformant, pull request.

When a field value is of the form ...{REF:...}...
Then:

* Auto-type does not work with that field
* References to this field are not properly resolved

This commit fixes both issues.
@TheZ3ro TheZ3ro added this to the v2.3.1 milestone Mar 5, 2018
Copy link
Contributor

@TheZ3ro TheZ3ro left a comment

Choose a reason for hiding this comment

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

We need to refactor this code in 2.4.
Anyway thanks for the contribution!

(I will add tests after merging this, seems strange that we didn't caught this)

@TheZ3ro TheZ3ro merged commit 1862861 into keepassxreboot:release/2.3.1 Mar 5, 2018
@salsifis salsifis deleted the release/2.3.1 branch March 6, 2018 17:00
phoerious added a commit that referenced this pull request Mar 6, 2018
- Fix unnecessary automatic upgrade to KDBX 4.0 and prevent challenge-response key being stripped [#1568]
- Abort saving and show an error message when challenge-response fails [#1659]
- Support inner stream protection on all string attributes [#1646]
- Fix favicon downloads not finishing on some websites [#1657]
- Fix freeze due to invalid STDIN data [#1628]
- Correct issue with encrypted RSA SSH keys [#1587]
- Fix crash on macOS due to QTBUG-54832 [#1607]
- Show error message if ssh-agent communication fails [#1614]
- Fix --pw-stdin and filename parameters being ignored [#1608]
- Fix Auto-Type syntax check not allowing spaces and special characters [#1626]
- Fix reference placeholders in combination with Auto-Type [#1649]
- Fix qtbase translations not being loaded [#1611]
- Fix startup crash on Windows due to missing SVG libraries [#1662]
- Correct database tab order regression [#1610]
- Fix GCC 8 compilation error [#1612]
- Fix copying of advanced attributes on KDE [#1640]
- Fix member initialization of CategoryListWidgetDelegate [#1613]
- Fix inconsistent toolbar icon sizes and provide higher-quality icons [#1616]
- Improve preview panel geometry [#1609]
@phoerious phoerious added pr: bugfix Pull request that fixes a bug and removed bug labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: Auto-Type pr: bugfix Pull request that fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants