Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2022-06-06 04:56:48 +0300
committerJonathan White <support@dmapps.us>2022-06-06 05:17:07 +0300
commit477b0e1eb9dba2d203d362ae55fb3647d4156b9e (patch)
tree18e559428a181691c0e1b1fc99a79db3c56e0791
parentbc0a5a944035b35e1641a546a2f5ef791d3f612b (diff)
Auto-Type: PICKCHARS can specify attribute and ignore BEEPfeature/pickchars-attribute
* Fix #7726 - Ignore BEEP Auto-Type token when it includes spaces and numbers as well * Close #8103 - Allow specifying specific attribute to use with PICKCHARS. If none specified, it defaults to Password.
-rw-r--r--share/translations/keepassxc_en.ts4
-rw-r--r--src/autotype/AutoType.cpp25
-rw-r--r--tests/TestAutoType.cpp2
3 files changed, 24 insertions, 7 deletions
diff --git a/share/translations/keepassxc_en.ts b/share/translations/keepassxc_en.ts
index 6f625f943..7d1d0edb3 100644
--- a/share/translations/keepassxc_en.ts
+++ b/share/translations/keepassxc_en.ts
@@ -644,6 +644,10 @@
<source>Invalid placeholder: %1</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <source>Entry does not have attribute for PICKCHARS: %1</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>AutoTypeAssociationsModel</name>
diff --git a/src/autotype/AutoType.cpp b/src/autotype/AutoType.cpp
index 57299fb66..750053955 100644
--- a/src/autotype/AutoType.cpp
+++ b/src/autotype/AutoType.cpp
@@ -647,13 +647,26 @@ AutoType::parseSequence(const QString& entrySequence, const Entry* entry, QStrin
for (const auto& ch : totp) {
actions << QSharedPointer<AutoTypeKey>::create(ch);
}
- } else if (placeholder == "pickchars") {
- // Ignore this if we are syntax checking
+ } else if (placeholder.startsWith("pickchars")) {
+ // Reset to the original capture to preserve case
+ placeholder = match.captured(3);
+
+ auto attribute = EntryAttributes::PasswordKey;
+ if (placeholder.contains(":")) {
+ attribute = placeholder.section(":", 1);
+ if (!entry->attributes()->hasKey(attribute)) {
+ error = tr("Entry does not have attribute for PICKCHARS: %1").arg(attribute);
+ return {};
+ }
+ }
+
+ // Bail out if we are just syntax checking
if (syntaxOnly) {
continue;
}
- // Show pickchars dialog for entry's password
- auto password = entry->resolvePlaceholder(entry->password());
+
+ // Show pickchars dialog for the desired attribute
+ auto password = entry->resolvePlaceholder(entry->attribute(attribute));
if (!password.isEmpty()) {
PickcharsDialog pickcharsDialog(password);
if (pickcharsDialog.exec() == QDialog::Accepted && !pickcharsDialog.selectedChars().isEmpty()) {
@@ -746,8 +759,8 @@ AutoType::parseSequence(const QString& entrySequence, const Entry* entry, QStrin
mode = AutoTypeExecutor::Mode::VIRTUAL;
}
actions << QSharedPointer<AutoTypeMode>::create(mode);
- } else if (placeholder == "beep" || placeholder.startsWith("vkey") || placeholder.startsWith("appactivate")
- || placeholder.startsWith("c:")) {
+ } else if (placeholder.startsWith("beep") || placeholder.startsWith("vkey")
+ || placeholder.startsWith("appactivate") || placeholder.startsWith("c:")) {
// Ignore these commands
} else {
// Attempt to resolve an entry attribute
diff --git a/tests/TestAutoType.cpp b/tests/TestAutoType.cpp
index 235ba5a86..445735f9f 100644
--- a/tests/TestAutoType.cpp
+++ b/tests/TestAutoType.cpp
@@ -337,7 +337,7 @@ void TestAutoType::testAutoTypeSyntaxChecks()
QVERIFY2(AutoType::verifyAutoTypeSyntax("{S:FOO}{S:HELLO WORLD}", entry, error), error.toLatin1());
QVERIFY2(!AutoType::verifyAutoTypeSyntax("{S:SPECIAL_TOKEN{}}", entry, error), error.toLatin1());
- QVERIFY2(!AutoType::verifyAutoTypeSyntax("{BEEP 3 3}", entry, error), error.toLatin1());
+ QVERIFY2(AutoType::verifyAutoTypeSyntax("{BEEP 3 3}", entry, error), error.toLatin1());
QVERIFY2(AutoType::verifyAutoTypeSyntax("{BEEP 3}", entry, error), error.toLatin1());
QVERIFY2(AutoType::verifyAutoTypeSyntax("{VKEY 0x01}", entry, error), error.toLatin1());