summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt35
-rw-r--r--app/src/main/res/values/strings.xml2
3 files changed, 27 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1189c0bb..c0e7ec87 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
- Add GPG key selection step to onboarding flow
- Allow configuring an app-wide HTTP(S) proxy
- Add option to automatically sync repository on app launch
+- Add a quickfix for invalid HTTPS URLs that contain a custom port
## [1.12.1] - 2020-10-13
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 7f1bb6b3..235af58b 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt
@@ -87,17 +87,29 @@ class GitServerConfigActivity : BaseGitActivity() {
// 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
+ if (newUrl.contains(PORT_REGEX)) {
+ if (newUrl.startsWith("https://")) {
+ BasicBottomSheet.Builder(this)
+ .setTitleRes(R.string.https_scheme_with_port_title)
+ .setMessageRes(R.string.https_scheme_with_port_message)
+ .setPositiveButtonClickListener {
+ binding.serverUrl.setText(newUrl.replace(PORT_REGEX, "/"))
+ }
+ .build()
+ .show(supportFragmentManager, "SSH_SCHEME_WARNING")
+ return@setOnClickListener
+ } else if (!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,
@@ -241,6 +253,7 @@ class GitServerConfigActivity : BaseGitActivity() {
}
companion object {
+ private val PORT_REGEX = ":[0-9]{1,5}/".toRegex()
fun createCloneIntent(context: Context): Intent {
return Intent(context, GitServerConfigActivity::class.java).apply {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f8be3859..2e393994 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -407,6 +407,8 @@
<!-- 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>
+ <string name="https_scheme_with_port_title">HTTPS URL with custom port</string>
+ <string name="https_scheme_with_port_message">It looks like you are using a HTTPS URL with a custom port. This is not supported, and will cause problems down the line. Press OK to remove the port from your URL.</string>
<string name="sync_on_launch_title">Sync on launch</string>
<string name="sync_on_launch_summary">Sync passwords when application is launched</string>
<string name="syncing">Syncing…</string>