JDK-4310802 : HTMLEditorKit does not parse TAGs for Cp037 character encoding
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 2000-02-08
  • Updated: 2004-09-02
  • Resolved: 2003-09-05
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
5.0 tigerFixed
Related Reports
Relates :  
Relates :  
Description

Name: aaC67449			Date: 02/08/2000



HTMLEditorKit does not parse TAGs in Cp037 character encoding
See example which tries to display ./index.html using Cp037
It displays plain text only

#> java -Dfile.encoding=Cp037 TestWWW

#> java TestWWW # this displays correct html

------------------------- example ----------------
import java.util.*;
import javax.swing.text.html.*;
import javax.swing.text.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.io.*;

public class TestWWW {

   public static void main(String argv[]) {
  
      JFrame f=new JFrame();
      try {
            final JEditorPane ep=new JEditorPane();
            try {
                ep.setPage("file:index.html");
            } catch(FileNotFoundException e) {}
            ep.addMouseListener(new HTMLEditorKit.LinkController());
            ep.setEditable(false);  


            ep.addHyperlinkListener(new HyperlinkListener() {
                                 public void hyperlinkUpdate(HyperlinkEvent e){
                                     try {
                                       if(e.getEventType().equals(HyperlinkEvent
                                              .EventType.ACTIVATED)) {
                                           System.out.println("URL:"
                                                           +e.getURL());
                                           ep.setPage(e.getURL());   
                                       }
                                      } catch(Exception ex) {
                                           ex.printStackTrace();
                                      }
                                 }                  
                             });
          final JTextField ur=new JTextField("file:index.html",80);
          
          ur.addActionListener(new ActionListener() {
                                    public void actionPerformed(ActionEvent e) {
                                          try {
                                              ep.setPage(ur.getText());   
                                          } catch(Exception ex) {
                                               ex.printStackTrace();
                                          }
                                    }         
                               });


          JScrollPane  panel=new JScrollPane(ep);
          f.getContentPane().add(ur,"North");
          f.getContentPane().add(panel);
          f.setSize(300,300);
          f.setVisible(true);
          ep.isVisible();
      } catch(Exception e) {
          e.printStackTrace();
      }
  }
}

------------------------- index.html ----------------
<HTML>
<HEAD>
<TITLE>Test</TITLE>
</HEAD>
<BODY>

<H1>H1 test</H1>

<P>
<A HREF="index.html">
HREF test</A>
</P>
</BODY>
</HTML>


======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b19 VERIFIED IN: tiger-b63
13-09-2004

EVALUATION Name: anR10225 Date: 06/18/2003 The problem is that HTMLEditorKit.getStyleSheet() tries to load CSS file (default.css) in the default encoding, which is set to Cp037. But this encoding doesn't preserve ASCII characters, thus default.css couldn't be parsed properly. Changing HTMLEditorKit.getStyleSheet() line new InputStreamReader(is) onto new InputStreamReader(is, "ASCII") solves the problem. ====================================================================== Name: anR10225 Date: 06/18/2003 Since the method HTMLEditorKit.getStyleSheet() reads the fixed file 'default.css' which is assumed to be in ISO-8859-1 encoding think we should create Reader with explicit ISO-8859-1 charset and not rely on default charset. ======================================================================
13-09-2004