JDK-8149631 : rgb(...) CSS color values are not parsed properly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7,8u72,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • CPU: generic
  • Submitted: 2016-02-05
  • Updated: 2016-04-28
  • Resolved: 2016-04-05
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 9
9 b116Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) Client VM (build 25.72-b15, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
The Swing CSS parser in Java 8 fails to parse CSS colors values properly if there are any space characters inside the rgb(...) parentheses.

REGRESSION.  Last worked in version 6u43

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
border-top-color: rgb(255, 0, 0)
border-right-color: rgb(255, 0, 0)
border-bottom-color: rgb(255, 0, 0)
border-left-color: rgb(255, 0, 0)

The output with jdk1.6.0_37 is:
border-color: rgb(255, 0, 0)
ACTUAL -
border-top-color: rgb(255,

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.*;
import javax.swing.text.*;
import javax.swing.text.html.*;

public class StyleSheetTest {
	public static void main(String[] args) {
		final StyleSheet styleSheet = new StyleSheet();
		// "rgb(255,0,0)" works in Java 8!
		final String input = "rgb(255, 0, 0)";
		final AttributeSet attributeSet = styleSheet.getDeclaration("border-color:" + input + ";");
		for (Enumeration<?> e = attributeSet.getAttributeNames(); e.hasMoreElements(); ) {
			final Object key = e.nextElement();
			System.out.println(key + ": " + attributeSet.getAttribute(key));
		}
		
	}	
}
---------- END SOURCE ----------


Comments
regression of JDK-4419748
14-03-2016