From 94d06a1317a34b00e07a46dff121c17d0ed53a28 Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 3 Mar 2019 15:58:05 +0100 Subject: [PATCH 1/4] Readme fixes --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 567e070..22bc513 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ - +

@@ -63,5 +63,4 @@ Whether you have ideas, translations, design changes, code cleaning, or real hea ## Donate - \ No newline at end of file From 133f346e45080ad934ff7656dab5357e6bb904c4 Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 3 Mar 2019 16:00:23 +0100 Subject: [PATCH 2/4] Readme fixes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 22bc513..9f734af 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ - +

From 125448b87baf7b2536e2018267a627880f5ce943 Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 3 Mar 2019 16:01:03 +0100 Subject: [PATCH 3/4] Readme fixes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f734af..ec8ebd9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ - +

From b3b6fa0731430b13d89e76d32c3fcf1fe324ee62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Schu=CC=88ller?= Date: Sun, 3 Mar 2019 21:58:10 +0100 Subject: [PATCH 4/4] Prevent bad server entry --- CHANGELOG.md | 3 +++ .../peertube/activity/SelectServerActivity.java | 11 ++++++++--- .../net/schueller/peertube/helper/APIUrlHelper.java | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6a0853..c56cc89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### Version 1.0.29 Tag: v1.0.29 (2019-03-03) +* Prevent entry of bad URL + ### Version 1.0.28 Tag: v1.0.28 (2019-03-03) * Server selection * Lots of translations diff --git a/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java b/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java index d29a8fa..b2da65f 100644 --- a/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/SelectServerActivity.java @@ -13,6 +13,7 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; +import android.util.Patterns; import android.view.View; import android.widget.Button; import android.widget.TextView; @@ -65,10 +66,14 @@ public class SelectServerActivity extends AppCompatActivity { String serverUrl = APIUrlHelper.cleanServerUrl(selectedUrl.getText().toString()); - editor.putString("pref_api_base", serverUrl); - editor.apply(); + if (!Patterns.WEB_URL.matcher(serverUrl).matches()) { + Toast.makeText(this, R.string.invalid_url, Toast.LENGTH_LONG).show(); + } else { + editor.putString("pref_api_base", serverUrl); + editor.apply(); + this.finish(); + } - this.finish(); }); } diff --git a/app/src/main/java/net/schueller/peertube/helper/APIUrlHelper.java b/app/src/main/java/net/schueller/peertube/helper/APIUrlHelper.java index 3cc5a00..cf24b2f 100644 --- a/app/src/main/java/net/schueller/peertube/helper/APIUrlHelper.java +++ b/app/src/main/java/net/schueller/peertube/helper/APIUrlHelper.java @@ -20,7 +20,9 @@ package net.schueller.peertube.helper; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; +import android.util.Patterns; import android.webkit.URLUtil; +import android.widget.Toast; import net.schueller.peertube.R; @@ -53,6 +55,8 @@ public class APIUrlHelper{ String cleanUrl = url.toLowerCase(); + cleanUrl = cleanUrl.replace(" ", ""); + if (!cleanUrl.startsWith("http")) { cleanUrl = "https://" + cleanUrl; }