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

Nonexistent html entities not parsed properly.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b140
    • CPU:
      x86
    • OS:
      linux
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.6.0_18"
        OpenJDK Runtime Environment (IcedTea6 1.8.3) (fedora-45.1.8.3.fc13-x86_64)
        OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Linux toto 2.6.34.7-61.fc13.x86_64 #1 SMP Tue Oct 19 04:06:30 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux

        A DESCRIPTION OF THE PROBLEM :
        After parsing, any text such as &X will be turned into &X;
        That's because the html parser assumes that there is an entity following the '&', and when it can't find the entity, it tries to put back the text. When doing this, it puts the semicolon, even if there was none in the input text.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the provided source.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        &a
        should be printed to standard out.
        ACTUAL -
        &a;
        is printed.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import javax.swing.JTextPane;
        import javax.swing.text.BadLocationException;

        public class TestTextPane {
        public static void main(String[] args) throws BadLocationException {
        JTextPane pane = new JTextPane();
        pane.setContentType("text/html");{
        String content = "&a";
        pane.setText(content);

        System.out.println(pane.getDocument().getText(0, pane.getDocument().getLength()));
        }
        }

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

        CUSTOMER SUBMITTED WORKAROUND :
        Use valid html - leaving the semicolon out is not valid.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                rupashka Pavel Porvatov (Inactive)
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: