8144300: http.nonProxyHosts value having wildcard * both at end and start are not honored
authorrpatil
Mon, 26 Mar 2018 17:33:58 +0530
changeset 49435 5fd26ab491fa
parent 49434 951f29c9aef5
child 49436 0fdb76741c56
8144300: http.nonProxyHosts value having wildcard * both at end and start are not honored Summary: added validation for wildcard at start and end Reviewed-by: chegar, dfuchs, clanger Contributed-by: pallavi.sonal@oracle.com
src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java
test/jdk/java/net/ProxySelector/B8035158.java
--- a/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java	Wed Mar 28 10:24:26 2018 +0200
+++ b/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java	Mon Mar 26 17:33:58 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -395,7 +395,9 @@
      */
     static String disjunctToRegex(String disjunct) {
         String regex;
-        if (disjunct.startsWith("*")) {
+        if (disjunct.startsWith("*") && disjunct.endsWith("*")) {
+            regex = ".*" + quote(disjunct.substring(1, disjunct.length() - 1)) + ".*";
+        } else if (disjunct.startsWith("*")) {
             regex = ".*" + quote(disjunct.substring(1));
         } else if (disjunct.endsWith("*")) {
             regex = quote(disjunct.substring(0, disjunct.length() - 1)) + ".*";
--- a/test/jdk/java/net/ProxySelector/B8035158.java	Wed Mar 28 10:24:26 2018 +0200
+++ b/test/jdk/java/net/ProxySelector/B8035158.java	Mon Mar 26 17:33:58 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8035158 8145732
+ * @bug 8035158 8145732 8144300
  * @run main/othervm B8035158
  */
 
@@ -153,6 +153,8 @@
         t.add(new TestCase("p-proxy.com", "http://p-proxy.com", false));
         t.add(new TestCase("google.co*|google.ie", "http://google.co.uk",
                 false));
+        t.add(new TestCase("*google.*", "http://google.co.uk",
+                false));
 
         t.add(new TestCase("*oracle.com", "http://my.oracle.com", false));
         t.add(new TestCase("google.com|bing.com|yahoo.com", "http://127.0.0.1", false));