diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2021-01-27 11:12:23 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-27 11:12:23 +0530 |
commit | 1f8db46ade8a7c25deb568b8a5988ee7b340b9c1 (patch) | |
tree | a698d0a5f384d61bb6a2acaded93ed3032a319d4 /app/src/main/java/dev | |
parent | 94420210f99a846ff489482298a6d54145598945 (diff) |
Disallow overwriting passwords when editing (#1286)
Co-authored-by: Aditya Wasan <adityawasan55@gmail.com>
Diffstat (limited to 'app/src/main/java/dev')
-rw-r--r-- | app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt index f4e6ac87..43e9b70b 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt @@ -398,7 +398,10 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB runCatching { val file = File(path) // If we're not editing, this file should not already exist! - if (!editing && file.exists()) { + // Additionally, if we were editing and the incoming and outgoing + // filenames differ, it means we renamed. Ensure that the target + // doesn't already exist to prevent an accidental overwrite. + if ((!editing || (editing && suggestedName != file.nameWithoutExtension)) && file.exists()) { snackbar(message = getString(R.string.password_creation_duplicate_error)) return@executeApiAsync } |