JDK-4407646 : JavaHelp Content Viewer displays raw html when used over https connection
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 1.3.0
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_8
  • CPU: sparc
  • Submitted: 2001-01-24
  • Updated: 2002-03-01
  • Resolved: 2001-03-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other
1.3.0_03 03Fixed 1.3.1_01Fixed
Related Reports
Relates :  
Description
Scenario: JavaHelp is invoked by an applet running in the Java Plug-in (Tested with 1.3.0 and 1.3.0_01). If a secure connection (https) is being used the Content Viewer that displays the Help Topics will display raw, unrendered html. 

The original tests were made with the following configuration:

Client: any version of MS Windows, Microsoft Internet Explorer 5.5 with the
Java Plug-in 1.3.0_01.

Server: a Sun server, running Apache/1.3.12 (Unix), tomcat/1.0,
mod_ssl/2.6.6, and OpenSSL/0.9.6 on Solaris 8

In the original test case, which can be made available, the HelpSet was built using the following code:

        private static HelpSet jh = null;
        private static HelpBroker jb = null;
        private static JApplet myApplet;

        public static void showHelp()
        {
                if (jb == null)
                {
                        String foobar = new String();
                        ClassLoader loader = foobar.getClass().getClassLoader();
                        URL codebase, url;
                        try
                        {
                                codebase = myApplet.getCodeBase();
       
                                url = new URL(codebase, "Help/Sentences_Online_Help.hs");
                                jh = new HelpSet(loader, url);
       
                                jb = jh.createHelpBroker();
                        } catch (Exception e)
                        {
                                processException(e);
                                return;
                        }
                }
                jb.setDisplayed(true);

The html files for each help topic are retrieved via https using the original codebase and the required filename. The page is displayed by a subclass of JEditorPane. The problem seems to be that at some point URLConnection.getContentType() is called and this returns null because of the underlying secure connection. Normally this call to getContentType() would return "text/html".

The problem can be simplified by removing JavaHelp from the equation. Create a plugin applet which contains a  JEditorPane. Call the JEditorPane's setPage() method to load a page from the server using https as the protocol (as specified in the URL) and the page will displayed as raw, unrendered html. 

Another test can be made where a URLConnection is made back to the web server using https as the protocol and then calling getContentType() on the URLConnection. This will return null.

In both of these cases, changing the protocol specified in URL from https to http gives the expected results, JEditorPane will render and display the html and URLConnection.getContentType() will return "text/html"

two test cases are provided that can be deployed with a secure web server.

The first is HttpsTestCase1.java and testcase1.html 
the second is HttpsTestCase2.java and testcase2.html

Both are included in the file testcase.jar.


Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.3.0_03 1.3.1_01 FIXED IN: 1.3.0_03 1.3.1_01 INTEGRATED IN: 1.3.0_03 1.3.1_01 VERIFIED IN: 1.3.0_03 1.3.1_01a
14-06-2004

WORK AROUND None
11-06-2004

SUGGESTED FIX ------- BrowserHttpsURLConnection.java ------- *** /tmp/duzaqgY Thu Feb 8 10:35:23 2001 --- BrowserHttpsURLConnection.java Wed Feb 7 18:47:22 2001 *************** *** 164,169 **** --- 164,172 ---- * @since JDK1.0 */ public String getHeaderField(String name) { + try { + getInputStream(); + } catch (IOException e) { } if (responseHeaders!=null) return responseHeaders.findValue(name); return null;
11-06-2004

PUBLIC COMMENTS When JavaHelp is invoked by an applet running in the Java Plug-in (Tested with 1.3.0 and 1.3.0_01). If a secure connection (https) is being used the Content Viewer that displays the Help Topics will display raw, unrendered html.
10-06-2004

EVALUATION The issue appears to be that sun.plugin.protocol.https.BrowserHttpsURLConnection.getHeaderField() isn't doing a getInputStream() so that we don't have the https connection establish and we don't have the http response fields at this time. As per the http protocol handler it is important to obtain the input stream before examining the response fields. As this is a plugin issue I am re-assigning this bug. alan.bateman@ireland 2001-02-06 In sun.plugin.protocol.https.BrowserHttpsURLConnection.getHeaderField(), calling getInputStream() before examining the responseHeaders fixes the problem. See suggested fix for details of code diff. calvin.cheung@eng 2001-02-08
08-02-2001