From: masensio Date: Tue, 21 Apr 2015 11:50:13 +0000 (+0200) Subject: Filter dots at the beginning of the url X-Git-Tag: test~29^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/870b8c0726b80ed84b951b698e4801c5fc078294?ds=inline;hp=-c Filter dots at the beginning of the url --- 870b8c0726b80ed84b951b698e4801c5fc078294 diff --git a/owncloud-android-library b/owncloud-android-library index 4692c4aa..9e761387 160000 --- a/owncloud-android-library +++ b/owncloud-android-library @@ -1 +1 @@ -Subproject commit 4692c4aadeba1d741b2b164af480c929ad4c17e9 +Subproject commit 9e761387a0b406402684571f28c36c2d6d2b6301 diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index d43df3f3..ccb0f854 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -776,9 +776,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity if (uri.length() != 0) { // Handle internationalized domain names - if (!uri.startsWith(".")) { - uri = DisplayUtils.convertIdn(uri, true); - } + uri = DisplayUtils.convertIdn(uri, true); + mServerStatusText = R.string.auth_testing_connection; mServerStatusIcon = R.drawable.progress_small; showServerStatus(); diff --git a/src/com/owncloud/android/utils/DisplayUtils.java b/src/com/owncloud/android/utils/DisplayUtils.java index c18a0e48..91dfc47c 100644 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/src/com/owncloud/android/utils/DisplayUtils.java @@ -257,11 +257,18 @@ public class DisplayUtils { */ @TargetApi(Build.VERSION_CODES.GINGERBREAD) public static String convertIdn(String url, boolean toASCII) { - + + String urlNoDots = url; + String dots=""; + while (urlNoDots.startsWith(".")) { + urlNoDots = url.substring(1); + dots = dots + "."; + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { // Find host name after '//' or '@' int hostStart = 0; - if (url.indexOf("//") != -1) { + if (urlNoDots.indexOf("//") != -1) { hostStart = url.indexOf("//") + "//".length(); } else if (url.indexOf("@") != -1) { hostStart = url.indexOf("@") + "@".length(); @@ -269,14 +276,14 @@ public class DisplayUtils { int hostEnd = url.substring(hostStart).indexOf("/"); // Handle URL which doesn't have a path (path is implicitly '/') - hostEnd = (hostEnd == -1 ? url.length() : hostStart + hostEnd); + hostEnd = (hostEnd == -1 ? urlNoDots.length() : hostStart + hostEnd); - String host = url.substring(hostStart, hostEnd); + String host = urlNoDots.substring(hostStart, hostEnd); host = (toASCII ? IDN.toASCII(host) : IDN.toUnicode(host)); - return url.substring(0, hostStart) + host + url.substring(hostEnd); + return dots + urlNoDots.substring(0, hostStart) + host + urlNoDots.substring(hostEnd); } else { - return url; + return dots + url; } }