8167223: URL handling improvements
authormichaelm
Thu, 17 Nov 2016 16:59:18 +0000
changeset 43215 f3d46da34ae9
parent 43214 3dd7af9b9e05
child 43216 c0f498d6a804
8167223: URL handling improvements Reviewed-by: prappo, chegar
jdk/src/java.base/share/classes/java/net/URLStreamHandler.java
--- a/jdk/src/java.base/share/classes/java/net/URLStreamHandler.java	Thu Nov 17 02:08:53 2016 +0000
+++ b/jdk/src/java.base/share/classes/java/net/URLStreamHandler.java	Thu Nov 17 16:59:18 2016 +0000
@@ -161,9 +161,9 @@
             (spec.charAt(start + 1) == '/')) {
             start += 2;
             i = spec.indexOf('/', start);
-            if (i < 0) {
+            if (i < 0 || i > limit) {
                 i = spec.indexOf('?', start);
-                if (i < 0)
+                if (i < 0 || i > limit)
                     i = limit;
             }
 
@@ -171,8 +171,14 @@
 
             int ind = authority.indexOf('@');
             if (ind != -1) {
-                userInfo = authority.substring(0, ind);
-                host = authority.substring(ind+1);
+                if (ind != authority.lastIndexOf('@')) {
+                    // more than one '@' in authority. This is not server based
+                    userInfo = null;
+                    host = null;
+                } else {
+                    userInfo = authority.substring(0, ind);
+                    host = authority.substring(ind+1);
+                }
             } else {
                 userInfo = null;
             }