Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit b21fe7a

Browse files
committed
Check if serverUrl is a vaild url or ip address.
1 parent 5b3032e commit b21fe7a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

app/src/main/java/com/zulip/android/activities/LoginActivity.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,22 @@ public void onSaveInstanceState(Bundle savedInstanceState){
250250
savedInstanceState.putString(PASSWORD,mPassword.getText().toString());
251251
}
252252

253+
private boolean isUrlValid(String url) {
254+
if (BuildConfig.DEBUG) {
255+
return URLUtil.isValidUrl(String.valueOf(url)) ||
256+
Patterns.IP_ADDRESS.matcher(url).matches();
257+
} else {
258+
return URLUtil.isValidUrl(String.valueOf(url));
259+
}
260+
}
261+
253262
private void showBackends(String httpScheme, String serverURL) {
254263
// if server url does not end with "/", then append it
255264
if (!serverURL.endsWith("/")) {
256265
serverURL = serverURL + "/";
257266
}
258267

259-
boolean isValid = URLUtil.isValidUrl(String.valueOf(serverURL));
260-
261-
if (!isValid){
268+
if (!isUrlValid(serverURL)){
262269
Toast.makeText(LoginActivity.this, R.string.invalid_url , Toast.LENGTH_SHORT).show();
263270
return;
264271
}

0 commit comments

Comments
 (0)