Merge remote-tracking branch 'origin/pinEnhancement' into pinEnhancement
[pub/Android/ownCloud.git] / src / com / owncloud / android / utils / DisplayUtils.java
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
     @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 (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
                 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
 \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
 \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
             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
         } else {\r
-            return url;\r
+            return dots + url;\r
         }\r
     }\r
 \r
         }\r
     }\r
 \r