JDK-6356875 : Differing implementation of dnsDomainIs when running JavaScript proxy settings
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-11-30
  • Updated: 2010-04-02
  • Resolved: 2006-01-17
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Internet Explorer Ver 6.0.2800.1106.xpsp2.050301-1526CO

A DESCRIPTION OF THE PROBLEM :
The Java plugin appears to define its own version of dnsDomainIs when running JavaScript proxy settings.  This version differs from Internet Explorer's version.

Unlike the IE dnsDomainIs, the Java plugin's implementation will only return true if the domain parameter starts with '.'.   IE dnsDomainIs will match exact hostnames.  Java plugin dnsDomainIs will not.

Example:
When loading a page with IE, dnsDomainIs("host.com", "host.com") returns true.
When loading an applet through IE with the Java plugin, dnsDomainIs("host.com", "host.com") returns false.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Put the source code (provided in the "Source Code" section of the bug report) into a .js file.
2. Tell the browser to use that file as the proxy settings.
3. Make sure the Java control panel is set to "use browser settings".
4. Open IE and go to any page.  An alert should pop up once with test results.
5. Go to a page with an applet.  The Java VM will load the proxy settings and will run the proxy script.  The alert box will show different results.



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
For both IE page loads and Java plugin applet loads, the dnsDomainIs function should return identical results.

When loading a page with IE, dnsDomainIs("host.com", "host.com") returns true.
Therefore, it should also return true with the Java plugin version of the function.


ACTUAL -
When loading a page with IE, dnsDomainIs("host.com", "host.com") returns true.
When loading an applet through IE with the Java plugin, dnsDomainIs("host.com", "host.com") returns false.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
var testDNSDomainIsFirstTime = true;

function testDNSDomainIs(host, domain) {
    var out = host + " is in " + domain + ": ";
    alert(out + dnsDomainIs(host, domain));
}

function FindProxyForURL(url, host) {
    // Only run the test once for regular requests from IE.
    // Run it for all .jar requests (which come from the Java VM).
    if (testDNSDomainIsFirstTime || (url.indexOf(".jar") >= 0)) {
        testDNSDomainIs("myhost.fake.com", "myhost.fake.com");
        testDNSDomainIs("myhost.fake.com", ".fake.com");
        testDNSDomainIsFirstTime = false;
    }
    
    return "DIRECT";
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
When testing domains in a JavaScript proxy config file, instead of:

dnsDomainIs(host, "host.test.com")

use:

(dnsDomainIs(host, "host.test.com") || (host == "host.test.com"))

This may not cover subdomains of host.test.com (but it meets our needs).