JDK-7003777 : Nonexistent html entities not parsed properly.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2010-12-01
  • Updated: 2013-11-27
  • Resolved: 2011-05-12
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.
JDK 6 JDK 7
6Fixed 7 b140Fixed
Related Reports
Relates :  
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
EVALUATION An initial and parsed values should be the same.
16-12-2010

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