Changeset 36050 in webkit


Ignore:
Timestamp:
Sep 2, 2008 11:51:31 PM (16 years ago)
Author:
mrowe@apple.com
Message:

2008-09-02 Glenn Wilson <wilsong@gmail.com>

Reviewed by Darin Adler.

Fix for <https://bugs.webkit.org/show_bug.cgi?id=15360>
Bug 15360: color:#{predefined colorName} is treated as colorName in Safari

We would inappropriately interpret and apply an invalid CSS "color" property
when the value is a predefined color preceded by a '#' symbol. For example,
style="color:#gray;" would apply the color gray when it should not.

In the bison template, "hexcolor" was defined as both "HEX maybe_space" OR "IDENT maybe_space".
This caused identifiers not fitting the appropriate hex format but preceded by a '#' to be
interpreted as a valid color (CSSPrimitiveValue::CSS_PARSER_HEXCOLOR), when it was really just
an ignorable token.

To correct this, "IDENT maybe_space" was removed from "hexcolor" and added under "term" as
'#' IDENT maybe_space, which is then processed as a CSSPrimitiveValue::CSS_STRING instead of
CSSPrimitiveValue::CSS_PARSER_HEXCOLOR.

Test: css1/color_and_background/invalid_color.html

  • css/CSSGrammar.y:

2008-09-02 Glenn Wilson <wilsong@gmail.com>

Reviewed by Darin Adler.

Test for <https://bugs.webkit.org/show_bug.cgi?id=15360>
Bug 15360: color:#{predefined colorName} is treated as colorName in Safari

Added new test to verify that CSS "color" attributes with '#'-preceeded predefined color names
are not rendered in those colors.

  • css1/color_and_background/invalid_color.html: Added.
  • css1/color_and_background/invalid_color-expected.txt: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r36047 r36050  
     12008-09-02  Glenn Wilson  <wilsong@gmail.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Test for <https://bugs.webkit.org/show_bug.cgi?id=15360>
     6        Bug 15360: color:#{predefined colorName} is treated as colorName in Safari
     7
     8        Added new test to verify that CSS "color" attributes with '#'-preceeded predefined color names
     9        are not rendered in those colors.
     10
     11        * css1/color_and_background/invalid_color.html: Added.
     12        * css1/color_and_background/invalid_color-expected.txt: Added.
     13
    1142008-09-02  Mihnea Ovidenie  <mihnea@adobe.com>
    215
  • trunk/WebCore/ChangeLog

    r36047 r36050  
     12008-09-02  Glenn Wilson  <wilsong@gmail.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Fix for <https://bugs.webkit.org/show_bug.cgi?id=15360>
     6        Bug 15360: color:#{predefined colorName} is treated as colorName in Safari
     7
     8        We would inappropriately interpret and apply an invalid CSS "color" property
     9        when the value is a predefined color preceded by a '#' symbol.  For example,
     10        style="color:#gray;" would apply the color gray when it should not.
     11
     12        In the bison template, "hexcolor" was defined as both "HEX maybe_space" OR "IDENT maybe_space".
     13        This caused identifiers not fitting the appropriate hex format but preceded by a '#' to be
     14        interpreted as a valid color (CSSPrimitiveValue::CSS_PARSER_HEXCOLOR), when it was really just
     15        an ignorable token.
     16
     17        To correct this, "IDENT maybe_space" was removed from "hexcolor" and added under "term" as
     18        '#' IDENT maybe_space, which is then processed as a CSSPrimitiveValue::CSS_STRING instead of
     19        CSSPrimitiveValue::CSS_PARSER_HEXCOLOR.
     20
     21        Test: css1/color_and_background/invalid_color.html
     22
     23        * css/CSSGrammar.y:
     24
    1252008-09-02  Mihnea Ovidenie  <mihnea@adobe.com>
    226
  • trunk/WebCore/css/CSSGrammar.y

    r35580 r36050  
    13291329  | UNICODERANGE maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_UNICODE_RANGE }
    13301330  | hexcolor { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_PARSER_HEXCOLOR; }
     1331  | '#' IDENT maybe_space { $$.id = 0; $$.string = $2; $$.unit = CSSPrimitiveValue::CSS_STRING; } /* Handle error case: "color:#{predefined color name};" */
    13311332  | '#' maybe_space { $$.id = 0; $$.string = CSSParserString(); $$.unit = CSSPrimitiveValue::CSS_PARSER_HEXCOLOR; } /* Handle error case: "color: #;" */
    13321333  /* FIXME: according to the specs a function can have a unary_operator in front. I know no case where this makes sense */
     
    14071408hexcolor:
    14081409  HEX maybe_space { $$ = $1; }
    1409   | IDSEL maybe_space { $$ = $1; }
    1410   ;
    1411 
     1410  ;
    14121411
    14131412/* error handling rules */
Note: See TracChangeset for help on using the changeset viewer.