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

HTMLEditorKit.write(...,int pos, int len) incorrectly works with pos and len.

XMLWordPrintable

    • 1.2.2
    • sparc
    • solaris_2.5.1



      Name: aaC67449 Date: 08/27/98



      HTMLEditorKit.write(...,int pos, int len) incorrectly works with pos and len.
      It writes incorrect html text, missing tags, writes unexpected part of text
      See example.


      --------------------- Example ----------------
      import com.sun.java.swing.text.html.*;
      import com.sun.java.swing.text.*;
      import java.io.*;
      public class Test {

         public static void main(String argv[]) {
              
      String test="<!DOCTYPE HTML PUBLIC \"-//w3c//DTD html 3.2//EN\"><HTML><HEAD><TITLE>test</TITLE></HEAD><body><P>Test</P></body></html>";

      HTMLEditorKit c= new HTMLEditorKit();
              Document doc=c.createDefaultDocument();
              try {
                 c.read(new StringReader(test),doc,0);
                 StringWriter sw= new StringWriter();
                 System.out.println("Missing tag <HEAD>\n---------------------");
                 c.write(sw,doc,1,6);
                 System.out.println(sw.toString());
                 System.out.println("Write unexpected part of text (Should write only one character)\n----------------");
                 c.write(sw,doc,6,1);
                 System.out.println(sw.toString());
             
      } catch(Exception e) {
                  e.printStackTrace();
              }
        
         }

      }

      ---------------- output ----------

      Missing tag <HEAD>
      ---------------------
      <html>
        <title>test </title>
        </head>
        

        <body>
          <p>
            Test
          </p>
        </body>
      </html>
       
      Write unexpected part of text (Should write only one character)
      ----------------
      <html>
        <title>test </title>
        </head>
        
       
        <body>
          <p>
            Test
          </p>
        </body>
      </html>
      <html>
        <body>
          <p>
            Test
          </p>
        </body>
      </html>
       


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

            svioletsunw Scott Violet (Inactive)
            aalievsunw Artem Aliev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: