Filter dots at the beginning of the url
authormasensio <masensio@solidgear.es>
Tue, 21 Apr 2015 11:50:13 +0000 (13:50 +0200)
committermasensio <masensio@solidgear.es>
Tue, 21 Apr 2015 11:50:13 +0000 (13:50 +0200)
owncloud-android-library
src/com/owncloud/android/authentication/AuthenticatorActivity.java
src/com/owncloud/android/utils/DisplayUtils.java

index 4692c4a..9e76138 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 4692c4aadeba1d741b2b164af480c929ad4c17e9
+Subproject commit 9e761387a0b406402684571f28c36c2d6d2b6301
index d43df3f..ccb0f85 100644 (file)
@@ -776,9 +776,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
 \r
         if (uri.length() != 0) {\r
             // Handle internationalized domain names\r
-            if (!uri.startsWith(".")) {\r
-                uri = DisplayUtils.convertIdn(uri, true);\r
-            }\r
+            uri = DisplayUtils.convertIdn(uri, true);\r
+\r
             mServerStatusText = R.string.auth_testing_connection;\r
             mServerStatusIcon = R.drawable.progress_small;\r
             showServerStatus();\r
index c18a0e4..91dfc47 100644 (file)
@@ -257,11 +257,18 @@ public class DisplayUtils {
      */\r
     @TargetApi(Build.VERSION_CODES.GINGERBREAD)\r
     public static String convertIdn(String url, boolean toASCII) {\r
-        \r
+\r
+        String urlNoDots = url;\r
+        String dots="";\r
+        while (urlNoDots.startsWith(".")) {\r
+            urlNoDots = url.substring(1);\r
+            dots = dots + ".";\r
+        }\r
+\r
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {\r
             // Find host name after '//' or '@'\r
             int hostStart = 0;\r
-            if  (url.indexOf("//") != -1) {\r
+            if  (urlNoDots.indexOf("//") != -1) {\r
                 hostStart = url.indexOf("//") + "//".length();\r
             } else if (url.indexOf("@") != -1) {\r
                 hostStart = url.indexOf("@") + "@".length();\r
@@ -269,14 +276,14 @@ public class DisplayUtils {
 \r
             int hostEnd = url.substring(hostStart).indexOf("/");\r
             // Handle URL which doesn't have a path (path is implicitly '/')\r
-            hostEnd = (hostEnd == -1 ? url.length() : hostStart + hostEnd);\r
+            hostEnd = (hostEnd == -1 ? urlNoDots.length() : hostStart + hostEnd);\r
 \r
-            String host = url.substring(hostStart, hostEnd);\r
+            String host = urlNoDots.substring(hostStart, hostEnd);\r
             host = (toASCII ? IDN.toASCII(host) : IDN.toUnicode(host));\r
 \r
-            return url.substring(0, hostStart) + host + url.substring(hostEnd);\r
+            return dots + urlNoDots.substring(0, hostStart) + host + urlNoDots.substring(hostEnd);\r
         } else {\r
-            return url;\r
+            return dots + url;\r
         }\r
     }\r
 \r