United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7003777 Nonexistent html entities not parsed properly.
JDK-7003777 : Nonexistent html entities not parsed properly.

Details
Type:
Bug
Submit Date:
2010-12-01
Status:
Closed
Updated Date:
2013-11-27
Project Name:
JDK
Resolved Date:
2011-05-12
Component:
client-libs
OS:
linux
Sub-Component:
javax.swing
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Relates:

Sub Tasks

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.

                                    

Comments
PUBLIC COMMENTS

On 1.6.0_21-b07, the output is &a
On 1.7.0-ea-b55, the output is &a;
                                     
2010-12-07
EVALUATION

An initial and parsed values should be the same.
                                     
2010-12-16



Hardware and Software, Engineered to Work Together