1
0
mirror of https://github.com/etesync/android synced 2024-11-26 01:48:34 +00:00

Check base URL validity with new URI() instead of new URL() (fixes #184)

This commit is contained in:
rfc2822 2014-03-15 13:39:02 +01:00
parent e9a4a4f1ef
commit e38feed08b

View File

@ -10,8 +10,10 @@
******************************************************************************/
package at.bitfire.davdroid.syncadapter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.commons.lang.StringUtils;
import android.app.DialogFragment;
import android.app.Fragment;
@ -128,10 +130,10 @@ public class EnterCredentialsFragment extends Fragment implements TextWatcher {
// check host name
try {
URL url = new URL(URIUtils.sanitize(protocol + editBaseURL.getText().toString()));
if (url.getHost() == null || url.getHost().isEmpty())
URI uri = new URI(URIUtils.sanitize(protocol + editBaseURL.getText().toString()));
if (StringUtils.isBlank(uri.getHost()))
ok = false;
} catch (MalformedURLException e) {
} catch (URISyntaxException e) {
ok = false;
}