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

Commit 440caab

Browse files
committed
GitServerConfigActivity: add quick-fix for HTTPS URLs with custom ports
Signed-off-by: Harsh Shandilya <[email protected]>
1 parent f2d0c18 commit 440caab

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
1616
- Add GPG key selection step to onboarding flow
1717
- Allow configuring an app-wide HTTP(S) proxy
1818
- Add option to automatically sync repository on app launch
19+
- Add a quickfix for invalid HTTPS URLs that contain a custom port
1920

2021
## [1.12.1] - 2020-10-13
2122

app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,29 @@ class GitServerConfigActivity : BaseGitActivity() {
8787
// If url is of type [email protected]:12435/path/to/repo, then not adding `ssh://`
8888
// in the beginning will cause the port to be seen as part of the path. Let users know
8989
// about it and offer a quickfix.
90-
if (newUrl.contains(":[0-9]{1,5}/".toRegex()) && !newUrl.startsWith("ssh://")) {
91-
BasicBottomSheet.Builder(this)
92-
.setTitleRes(R.string.ssh_scheme_needed_title)
93-
.setMessageRes(R.string.ssh_scheme_needed_message)
94-
.setPositiveButtonClickListener {
95-
@Suppress("SetTextI18n")
96-
binding.serverUrl.setText("ssh://$newUrl")
97-
}
98-
.build()
99-
.show(supportFragmentManager, "SSH_SCHEME_WARNING")
100-
return@setOnClickListener
90+
if (newUrl.contains(PORT_REGEX)) {
91+
if (newUrl.startsWith("https://")) {
92+
BasicBottomSheet.Builder(this)
93+
.setTitleRes(R.string.https_scheme_with_port_title)
94+
.setMessageRes(R.string.https_scheme_with_port_message)
95+
.setPositiveButtonClickListener {
96+
binding.serverUrl.setText(newUrl.replace(PORT_REGEX, "/"))
97+
}
98+
.build()
99+
.show(supportFragmentManager, "SSH_SCHEME_WARNING")
100+
return@setOnClickListener
101+
} else if (!newUrl.startsWith("ssh://")) {
102+
BasicBottomSheet.Builder(this)
103+
.setTitleRes(R.string.ssh_scheme_needed_title)
104+
.setMessageRes(R.string.ssh_scheme_needed_message)
105+
.setPositiveButtonClickListener {
106+
@Suppress("SetTextI18n")
107+
binding.serverUrl.setText("ssh://$newUrl")
108+
}
109+
.build()
110+
.show(supportFragmentManager, "SSH_SCHEME_WARNING")
111+
return@setOnClickListener
112+
}
101113
}
102114
when (val updateResult = GitSettings.updateConnectionSettingsIfValid(
103115
newAuthMode = newAuthMode,
@@ -241,6 +253,7 @@ class GitServerConfigActivity : BaseGitActivity() {
241253
}
242254

243255
companion object {
256+
private val PORT_REGEX = ":[0-9]{1,5}/".toRegex()
244257

245258
fun createCloneIntent(context: Context): Intent {
246259
return Intent(context, GitServerConfigActivity::class.java).apply {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@
407407
<!-- SSH port validation -->
408408
<string name="ssh_scheme_needed_title">Potentially incorrect URL</string>
409409
<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>
410+
<string name="https_scheme_with_port_title">HTTPS URL with custom port</string>
411+
<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>
410412
<string name="sync_on_launch_title">Sync on launch</string>
411413
<string name="sync_on_launch_summary">Sync passwords when application is launched</string>
412414
<string name="syncing">Syncing…</string>

0 commit comments

Comments
 (0)