From eaada4c2e6a2df24dc163b5477b3d0be6448c8ee Mon Sep 17 00:00:00 2001 From: David Luhmer Date: Sun, 3 Nov 2019 17:39:01 +0100 Subject: [PATCH] fix validation of urls when using manual setup --- .../de/luhmer/owncloudnewsreader/LoginDialogActivity.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogActivity.java index 575401f8..01263be6 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogActivity.java @@ -36,6 +36,7 @@ import android.text.TextWatcher; import android.text.method.LinkMovementMethod; import android.text.util.Linkify; import android.util.Log; +import android.util.Patterns; import android.view.View; import android.widget.CheckBox; import android.widget.CompoundButton; @@ -321,9 +322,13 @@ public class LoginDialogActivity extends AppCompatActivity { } else { try { URL url = new URL(mOc_root_path); - if (!url.getProtocol().equals("https")) + if(!Patterns.WEB_URL.matcher(mOc_root_path).matches()) { + throw new MalformedURLException(); + } + if (!url.getProtocol().equals("https")) { ShowAlertDialog(getString(R.string.login_dialog_title_security_warning), getString(R.string.login_dialog_text_security_warning), this); + } } catch (MalformedURLException e) { mOc_root_path_View.setError(getString(R.string.error_invalid_url)); focusView = mOc_root_path_View;