Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 97bc1e0

Browse files
authored
Add snackbar error message when .gpg-id contains a short hex id (#2819)
1 parent ab87e9c commit 97bc1e0

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

app/src/main/java/app/passwordstore/ui/crypto/BasePGPActivity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ open class BasePGPActivity : AppCompatActivity() {
170170
if (line.isEmpty()) return@run
171171
// Apparently `gpg-id` being the first line is also acceptable?
172172
if (line == "gpg-id") return@run
173-
if (line.removePrefix("0x").matches("[a-fA-F0-9]{8}".toRegex()).not()) {
173+
if (line.removePrefix("0x").matches("[a-fA-F0-9]{8}".toRegex())) {
174+
snackbar(message = resources.getString(R.string.short_gpg_id))
175+
} else {
174176
snackbar(message = resources.getString(R.string.invalid_gpg_id))
175177
}
176178
return null

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@
305305
<string name="otp_import_failure_no_selection">No image file was selected</string>
306306
<string name="exporting_passwords">Exporting passwords…</string>
307307
<string name="invalid_gpg_id">Found .gpg-id, but it contains an invalid key ID, fingerprint or user ID</string>
308+
<string name="short_gpg_id">Found .gpg-id, but it contains a short hex ID, which is not supported</string>
308309
<string name="invalid_filename_text">File name must not contain \'/\', set directory above</string>
309310
<string name="directory_hint">Directory</string>
310311
<string name="new_folder_set_gpg_key">Set GPG key for directory</string>

0 commit comments

Comments
 (0)