diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2020-09-19 17:28:08 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2020-09-19 17:30:19 +0530 |
commit | e8e0cc791ffa92a9487d4bf2e1831f9ce34ee687 (patch) | |
tree | 6de13bbc2682a60eedf5923cfa1bda3ae3ae18c7 | |
parent | 5d5a068591e16a97f6cbbf6b75ecc2e5aed5bbf3 (diff) |
Add check for potential issues with SSH URL
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt | 17 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 4 |
3 files changed, 22 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bd290d2..13030724 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file. - Add ability to view the Git commit log - Allow generating ECDSA and ED25519 keys for SSH - Add support for multiple/fallback authentication methods for SSH +- Add warning when the custom SSH port in a URL could potentially be ignored ### Changed diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt index 92381384..0d4246b0 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt @@ -25,6 +25,7 @@ import com.zeapo.pwdstore.databinding.ActivityGitCloneBinding import com.zeapo.pwdstore.git.config.AuthMode import com.zeapo.pwdstore.git.config.GitSettings import com.zeapo.pwdstore.git.config.Protocol +import com.zeapo.pwdstore.ui.dialogs.BasicBottomSheet import com.zeapo.pwdstore.utils.PasswordRepository import com.zeapo.pwdstore.utils.snackbar import com.zeapo.pwdstore.utils.viewBinding @@ -87,6 +88,22 @@ class GitServerConfigActivity : BaseGitActivity() { } binding.saveButton.setOnClickListener { + val newUrl = binding.serverUrl.text.toString().trim() + // If url is of type john_doe@example.org:12435/path/to/repo, then not adding `ssh://` + // in the beginning will cause the port to be seen as part of the path. Let users know + // about it and offer a quickfix. + if (newUrl.contains(":[0-9]{1,5}/".toRegex()) && !newUrl.startsWith("ssh://")) { + BasicBottomSheet.Builder(this) + .setTitleRes(R.string.ssh_scheme_needed_title) + .setMessageRes(R.string.ssh_scheme_needed_message) + .setPositiveButtonClickListener { + @Suppress("SetTextI18n") + binding.serverUrl.setText("ssh://$newUrl") + } + .build() + .show(supportFragmentManager, "SSH_SCHEME_WARNING") + return@setOnClickListener + } when (val updateResult = GitSettings.updateConnectionSettingsIfValid( newAuthMode = newAuthMode, newUrl = binding.serverUrl.text.toString().trim(), diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 90295413..8c2e88b2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -436,4 +436,8 @@ <string name="err_enter_store_name">Enter a store name to continue</string> <string name="exception_cannot_create_directory">Cannot create new directory.</string> + <!-- SSH port validation --> + <string name="ssh_scheme_needed_title">Potentially incorrect URL</string> + <string name="ssh_scheme_needed_message">It appears that your URL contains a custom port, but does not specify the ssh:// scheme.\nThis can cause the port to be considered a part of your path. Press OK here to fix the URL.</string> + </resources> |