Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6563259

incorrect handling when including uppercase letter in hostname

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 5.0
    • Fix Version/s: 7
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Introduced In Version:
      5.0
    • Resolved In Build:
      b14
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Verified

      Backports

        Description

        From jdk 5.0, when setting http.ProxyHost/http.nonProxyHosts,
        including uppercase in java.net.URL's hostname will lead to incorrect
        handling. This can be seen in the following case.

        1.Java system properties
        http.proxyHost
        http.proxyPort
        http.nonProxyHosts

        2.Including uppercase in hostname when using
          java.net.URL#openConnection to access.

        e.g.
        Setting "HOST1" at http.nonProxyHosts and calling
        java.net.URL#openConnection to access [http://HOST1/].

        Setting "HOST2.sample.com" at http.nonProxyHosts and calling
        java.net.URL#openConnection to access [http://HOST2.sample.com/].

        Below are the snippets from jdk 5.0 and 1.4.2. In jdk 5.0, line 237
        transforms the string specified at system property to lower-case. But
        the hostname is not changed when being compared in line 246.

        In jdk 1.4.2 source, not only the string specified via
        nonProxyHosts(line 220), also the compared hostname is converted to
        lower-case(line 588).

        [5.0 DefaultProxySelector.java]
        -----
        109 public java.util.List<Proxy> select(URI uri) {
        110 if (uri == null) {
        111 throw new IllegalArgumentException("URI can't be null.");
        112 }
        113 String protocol = uri.getScheme();
        114 String host = uri.getHost();
        115 int port = uri.getPort();
           ...
        172 final String proto = protocol;
        173 final NonProxyInfo nprop = pinfo;
        174 final String urlhost = host;
          ...
        233 RegexpPool pool = new RegexpPool();
        234 StringTokenizer st = new StringTokenizer(nphosts, "|", false);
        235 try {
        236 while (st.hasMoreTokens()) {
        237 pool.add(st.nextToken().toLowerCase(), Boolean.TRUE);
        238 }
        239 } catch (sun.misc.REException ex) {
        240 }
        241 nprop.hostsPool = pool;
        242 nprop.hostsSource = nphosts;
        243 }
        244 }
        245 if (nprop.hostsPool != null &&
        246 nprop.hostsPool.match(urlhost) != null) {
        247 return Proxy.NO_PROXY;
        248 }
        249 }
        250 }
        -----

        [1.4.2 HttpClient.java]
        -----
        216 RegexpPool pool = new RegexpPool();
        217 StringTokenizer st = new StringTokenizer(rawList, "|", false);
        218 try {
        219 while (st.hasMoreTokens()) {
        220 pool.add(st.nextToken().toLowerCase(), Boolean.TRUE);
        221 }
        222 } catch (sun.misc.REException ex) {
        223 System.err.println("Error in http.nonProxyHosts system property: " + ex);
        224 }
          ...
        588 String urlHost = url.getHost().toLowerCase();
        589 boolean loopback = isLoopback(urlHost);
        590
        591 if (url.getProtocol().equals("http") ||
        592 url.getProtocol().equals("https") ) {
        593
        594 if ((instProxy != null) && !loopback) {
        595 privilegedOpenServer(instProxy, instProxyPort);
        596 usingProxy = true;
        597 return;
        598 }
        599
        600 String proxyHost = getProxyHost();
        601 if ((proxyHost != null) &&
        602 (!(proxyDisabled ||
        603 loopback ||
        604 matchNonProxyHosts(urlHost) ||
        605 matchNonProxyHosts(host)))) {
        -----

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                jccollet Jean-Christophe Collet (Inactive)
                Reporter:
                xiaojuzh Xiaojun Zhang (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: