From 318d5df2b2cae9f1e466ad6ece58ff49c3ed9215 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 31 Aug 2021 07:33:27 +0200 Subject: [PATCH] Allow entering IPv6 address --- app/src/main/java/eu/faircode/email/FragmentAccount.java | 7 +++---- app/src/main/java/eu/faircode/email/FragmentIdentity.java | 7 +++---- app/src/main/java/eu/faircode/email/FragmentPop.java | 7 +++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index 2e6905259c..9cc01c98cc 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -679,10 +679,9 @@ public class FragmentAccount extends FragmentBase { String realm = args.getString("realm"); String fingerprint = args.getString("fingerprint"); - if (host.contains(":")) { - Uri h = Uri.parse(host); - host = h.getHost(); - } + int semi = host.indexOf(':'); + if (semi > 0 && host.indexOf(':', semi + 1) < 0) + host = host.substring(0, semi); if (TextUtils.isEmpty(host)) throw new IllegalArgumentException(context.getString(R.string.title_no_host)); diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java index 2ade7cdefd..4ee78aec14 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java @@ -744,10 +744,9 @@ public class FragmentIdentity extends FragmentBase { boolean should = args.getBoolean("should"); - if (host.contains(":")) { - Uri h = Uri.parse(host); - host = h.getHost(); - } + int semi = host.indexOf(':'); + if (semi > 0 && host.indexOf(':', semi + 1) < 0) + host = host.substring(0, semi); //if (TextUtils.isEmpty(name) && !should) // throw new IllegalArgumentException(context.getString(R.string.title_no_name)); diff --git a/app/src/main/java/eu/faircode/email/FragmentPop.java b/app/src/main/java/eu/faircode/email/FragmentPop.java index d8ab09da79..47565233f5 100644 --- a/app/src/main/java/eu/faircode/email/FragmentPop.java +++ b/app/src/main/java/eu/faircode/email/FragmentPop.java @@ -374,10 +374,9 @@ public class FragmentPop extends FragmentBase { boolean pro = ActivityBilling.isPro(context); boolean should = args.getBoolean("should"); - if (host.contains(":")) { - Uri h = Uri.parse(host); - host = h.getHost(); - } + int semi = host.indexOf(':'); + if (semi > 0 && host.indexOf(':', semi + 1) < 0) + host = host.substring(0, semi); if (TextUtils.isEmpty(host) && !should) throw new IllegalArgumentException(context.getString(R.string.title_no_host));