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)
|
### Version 1.0.28 Tag: v1.0.28 (2019-03-03)
|
||||||
* Server selection
|
* Server selection
|
||||||
* Lots of translations
|
* Lots of translations
|
||||||
|
@ -13,6 +13,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.Patterns;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -65,10 +66,14 @@ public class SelectServerActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
String serverUrl = APIUrlHelper.cleanServerUrl(selectedUrl.getText().toString());
|
String serverUrl = APIUrlHelper.cleanServerUrl(selectedUrl.getText().toString());
|
||||||
|
|
||||||
|
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.putString("pref_api_base", serverUrl);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
|
|
||||||
this.finish();
|
this.finish();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,9 @@ package net.schueller.peertube.helper;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.util.Patterns;
|
||||||
import android.webkit.URLUtil;
|
import android.webkit.URLUtil;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.schueller.peertube.R;
|
import net.schueller.peertube.R;
|
||||||
|
|
||||||
@ -53,6 +55,8 @@ public class APIUrlHelper{
|
|||||||
|
|
||||||
String cleanUrl = url.toLowerCase();
|
String cleanUrl = url.toLowerCase();
|
||||||
|
|
||||||
|
cleanUrl = cleanUrl.replace(" ", "");
|
||||||
|
|
||||||
if (!cleanUrl.startsWith("http")) {
|
if (!cleanUrl.startsWith("http")) {
|
||||||
cleanUrl = "https://" + cleanUrl;
|
cleanUrl = "https://" + cleanUrl;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user