Skip to content

Commit

Permalink
Auto-Type: PICKCHARS can specify attribute and ignore BEEP
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
droidmonkey committed Jun 6, 2022
1 parent 924eb6d commit 9e31dd0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
4 changes: 4 additions & 0 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
25 changes: 19 additions & 6 deletions src/autotype/AutoType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9e31dd0

Please sign in to comment.