changeset 8614:7d4807d14247

8167223: URL handling improvements Reviewed-by: prappo, chegar
author aefimov
date Fri, 18 Nov 2016 14:46:18 +0300
parents bee8851bd076
children 3c911bfe30a9
files src/share/classes/java/net/URLStreamHandler.java
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/net/URLStreamHandler.java	Wed Oct 12 15:43:35 2016 +0300
+++ b/src/share/classes/java/net/URLStreamHandler.java	Fri Nov 18 14:46:18 2016 +0300
@@ -162,9 +162,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;
             }
 
@@ -172,8 +172,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;
             }