[fractal: 1/2] login: Don't remove the Homeserver schema unconditionally.
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal: 1/2] login: Don't remove the Homeserver schema unconditionally.
- Date: Sat, 12 Oct 2019 10:40:56 +0000 (UTC)
commit 78a3ef7d0fd50a6a34c60340d53180f3fb3ca4da
Author: Damir Jelić <poljar termina org uk>
Date: Sun Sep 29 11:40:48 2019 +0200
login: Don't remove the Homeserver schema unconditionally.
The current Homeserver URL parsing logic unconditionally removes the URL
schema if it's either "http://" or "https://", then prepends
the "https://" schema back immediately after.
While this correctly adds a "https://" schema for an URL without a
schema, it disallows connections to a non-TLS host. Synapse, rightfully
so, disallows non-TLS connections. Connecting to such a host might be
desirable anyway to connect to a logging/debugging reverse proxy such as
mitmproxy or to connect to Pantalaimon, a reverse proxy that enables
client-transparent E2E encryption.
Closes: https://gitlab.gnome.org/GNOME/fractal/issues/520
fractal-gtk/src/widgets/login.rs | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/fractal-gtk/src/widgets/login.rs b/fractal-gtk/src/widgets/login.rs
index 040822f9..7289a7c1 100644
--- a/fractal-gtk/src/widgets/login.rs
+++ b/fractal-gtk/src/widgets/login.rs
@@ -80,14 +80,12 @@ impl LoginWidget {
.get_text()
.map_or(String::new(), |gstr| gstr.to_string());
- let txt = format!(
- "{}{}",
- "https://",
- String::from(txt)
- .trim()
- .trim_start_matches("http://")
- .trim_start_matches("https://")
- );
+ let txt = String::from(txt).trim().to_string();
+ let txt = if txt.starts_with("http://") || txt.starts_with("https://") {
+ txt
+ } else {
+ format!("https://{}", &txt)
+ };
if !password.is_empty() && !username.is_empty() {
// take the user's homeserver value if the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]