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

rgb(...) CSS color values are not parsed properly

XMLWordPrintable

    • b116
    • generic

      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 ----------

            ssadetsky Semyon Sadetsky (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: