]> git.ktnx.net Git - mobile-ledger.git/commitdiff
require URL protocol to be HTTP or HTTPS
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 20 Jul 2019 18:45:58 +0000 (21:45 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 20 Jul 2019 18:45:58 +0000 (21:45 +0300)
app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java

index c995ade117221c277d077016d98c1dff52804b30..2e964d1c0977ab864f486b7bf836f97b492e4c45 100644 (file)
@@ -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;