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

JEditorPane does not render HTML BODY if a META tag is included in HEAD

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 6
    • client-libs

      FULL PRODUCT VERSION :
      1.6.0_05

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP SP2

      A DESCRIPTION OF THE PROBLEM :
      When the META tag "meta http-equiv" is included in the HEAD of some HTML, the BODY fails to get rendered. If it's removed, the BODY does get rendered.



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Here's the failing HTML:

      <html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <meta name="Generator" content="Microsoft Exchange Server">

      <style>EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; }</style></head>
      <body>
      <font size="2"><div class="PlainText">Your message was read on Monday, July 07, 2008 7:38:24 AM (GMT-08:00) Pacific Time (US &amp; Canada).</div></font>
      </body>
      </html>
      Your message was read on Monday, July 07, 2008 7:38:24 AM (GMT-08:00) Pacific Time (US & Canada).

      The following modified HTML works fine:

      <html><head>
      <meta name="Generator" content="Microsoft Exchange Server">

      <style>EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; }</style></head>
      <body>
      <font size="2"><div class="PlainText">Your message was read on Monday, July 07, 2008 7:38:24 AM (GMT-08:00) Pacific Time (US &amp; Canada).</div></font>
      </body>
      </html>
      Your message was read on Monday, July 07, 2008 7:38:24 AM (GMT-08:00) Pacific Time (US & Canada).

      Write the first HTML to a file "test_file.txt" and run the following Java application from the same directory:
      ---------------------------------------------------cut here-----------------------------------
      import javax.swing.*;
      import java.io.*;

      public class chiaratest
        {
        JFrame frame;

        JPanel panel;

        JEditorPane pane;

        RandomAccessFile file;

        String text;

        byte[] buf;

        public chiaratest(String input_parm)
          {
          frame= new JFrame();
          pane = new JEditorPane();
          pane.setContentType("text/html");

          try
            {
            file = new RandomAccessFile("test_file.txt", "r");
      buf = new byte[(int) file.length()];
      file.readFully(buf);
            text = new String(buf);
      }
          catch (Exception e)
            {
            System.out.println("e = " + e);
            System.exit(0);
            }
          pane.setText(text);
          panel = new JPanel();
          panel.add(pane);
          frame.getContentPane().add(panel);
          frame.pack();
          frame.setVisible(true);
          }

        public static void main(String args[])
          {
          new chiaratest(null);
          }
        }
      ---------------------------------------------------cut here-----------------------------------

      If you remove the first META tag and its data, the text will display.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The test application should display the following:

      Your message was read on Monday, July 07, 2008 7:38:24 AM (GMT-08:00) Pacific Time (US & Canada).
      ACTUAL -
      Nothing was displayed

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.io.*;

      public class chiaratest
        {
        JFrame frame;

        JPanel panel;

        JEditorPane pane;

        RandomAccessFile file;

        String text;

        byte[] buf;

        public chiaratest(String input_parm)
          {
          frame= new JFrame();
          pane = new JEditorPane();
          pane.setContentType("text/html");

          try
            {
            file = new RandomAccessFile("test_file.txt", "r");
      buf = new byte[(int) file.length()];
      file.readFully(buf);
            text = new String(buf);
      }
          catch (Exception e)
            {
            System.out.println("e = " + e);
            System.exit(0);
            }
          pane.setText(text);
          panel = new JPanel();
          panel.add(pane);
          frame.getContentPane().add(panel);
          frame.pack();
          frame.setVisible(true);
          }

        public static void main(String args[])
          {
          new chiaratest(null);
          }
        }

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

      CUSTOMER SUBMITTED WORKAROUND :
      This problem was described in bug report #4695909 and was supposedly fixed in JDK 1.5; however, I still see the bug in JDK 1.6.0_05

            peterz Peter Zhelezniakov
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: