From c9ccae28951a225ee55a107741250c1a1249aeb3 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 20 Jul 2019 21:45:58 +0300 Subject: [PATCH] require URL protocol to be HTTP or HTTPS --- .../mobileledger/ui/profiles/ProfileDetailFragment.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java index c995ade1..2e964d1c 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java @@ -257,6 +257,7 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue } @Override public void afterTextChanged(Editable s) { + checkValidity(); checkInsecureSchemeWithAuth(); } }); @@ -361,6 +362,11 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue URL url = new URL(val); String host = url.getHost(); if (host == null || host.isEmpty()) throw new MalformedURLException("Missing host"); + String protocol = url.getProtocol().toUpperCase(); + if (!protocol.equals("HTTP") && !protocol.equals("HTTPS")) { + valid = false; + urlLayout.setError(getResources().getText(R.string.err_invalid_url)); + } } catch (MalformedURLException e) { valid = false; -- 2.39.5