Prevent bad server entry
This commit is contained in:
parent
125448b87b
commit
b3b6fa0731
@ -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
|
||||
|
@ -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();
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user