JDK-7158257 : HTML entity for apostrophe character not replaced in JLabel
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_7
  • CPU: x86
  • Submitted: 2012-03-31
  • Updated: 2012-04-10
  • Resolved: 2012-04-03
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 8
8-poolResolved
Description
FULL PRODUCT VERSION :
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [version 6.1.7601] 64 bit


A DESCRIPTION OF THE PROBLEM :
When creating a JLabel with text equals to "<html>&apos;</html>", the text displayed by this JLabel is set to "&apos;", and not to the apostrophe character.

This bug seems to concern only the apostrophe character. All the other HTML entities we have tested are correctly escaped.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a JLabel as new JLabel("<html>&apos;</html>")
2. Look at the text displayed

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The text displayed should be an apostrophe.
ACTUAL -
The text "&apos;" is shown.

REPRODUCIBILITY :
This bug can be reproduced always.

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

public class Test {
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		JPanel panel = new JPanel();
		panel.add(new JLabel("<html>&quot;</html>")); // OK
		panel.add(new JLabel("<html>&apos;</html>")); // NOT OK !
		panel.add(new JLabel("<html>&amp;</html>")); // OK
		panel.add(new JLabel("<html>&lt;</html>")); // OK
		panel.add(new JLabel("<html>&gt;</html>")); // OK
		frame.add(panel);
		frame.setVisible(true);
	}
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Replace all "&apos;" sequences from HTML code by apostrophe characters before passing it to JLabel.

Comments
EVALUATION We supports HTML 3.2. But even according to HTML 4 specification (see http://www.w3.org/TR/html4/sgml/entities.html#h-24.4.1) there is no construcion "&apos;". So I'm closing CR as not a defect.
03-04-2012