Changeset 170933 in webkit
- Timestamp:
- Jul 9, 2014 2:56:05 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r170932 r170933 1 2014-07-09 Javier Fernandez <jfernandez@igalia.com> 2 3 CSS canvas color parsing accepts invalid color identifiers 4 https://bugs.webkit.org/show_bug.cgi?id=134661 5 6 Reviewed by Benjamin Poulain. 7 8 The parseSystemFunction determines now whether the parsed color is 9 valid or not. 10 11 The rgb-color-parser covers css style color parsing cases, which 12 already provide coverage for invalid color identifiers. I've added 13 a few more, though. 14 15 * fast/canvas/canvas-color-serialization-expected.txt: 16 * fast/canvas/script-tests/canvas-color-serialization.js: 17 * fast/css/test-setting-canvas-color-expected.txt: 18 * fast/css/test-setting-canvas-color.html: 19 * svg/dom/rgb-color-parser-expected.txt: 20 * svg/dom/rgb-color-parser.html: 21 1 22 2014-06-28 Jer Noble <jer.noble@apple.com> 2 23 -
trunk/LayoutTests/fast/canvas/canvas-color-serialization-expected.txt
r87512 r170933 130 130 PASS trySettingFillStyle(null) is '#666666' 131 131 PASS trySettingShadowColor(null) is '#666666' 132 PASS trySettingStrokeStyle('left') is '#666666' 133 PASS trySettingFillStyle('left') is '#666666' 134 PASS trySettingShadowColor('left') is '#666666' 135 PASS trySettingStrokeStyle('right') is '#666666' 136 PASS trySettingFillStyle('right') is '#666666' 137 PASS trySettingShadowColor('right') is '#666666' 138 PASS trySettingStrokeStyle('center') is '#666666' 139 PASS trySettingFillStyle('center') is '#666666' 140 PASS trySettingShadowColor('center') is '#666666' 141 PASS trySettingStrokeStyle('border') is '#666666' 142 PASS trySettingFillStyle('border') is '#666666' 143 PASS trySettingShadowColor('border') is '#666666' 144 PASS trySettingStrokeStyle('border-box') is '#666666' 145 PASS trySettingFillStyle('border-box') is '#666666' 146 PASS trySettingShadowColor('border-box') is '#666666' 147 PASS trySettingStrokeStyle('content') is '#666666' 148 PASS trySettingFillStyle('content') is '#666666' 149 PASS trySettingShadowColor('content') is '#666666' 150 PASS trySettingStrokeStyle('logical') is '#666666' 151 PASS trySettingFillStyle('logical') is '#666666' 152 PASS trySettingShadowColor('logical') is '#666666' 153 PASS trySettingStrokeStyle('visual') is '#666666' 154 PASS trySettingFillStyle('visual') is '#666666' 155 PASS trySettingShadowColor('visual') is '#666666' 132 156 PASS trySettingStrokeColorWithSetter('transparent') is 'rgba(0, 0, 0, 0)' 133 157 PASS trySettingFillColorWithSetter('transparent') is 'rgba(0, 0, 0, 0)' -
trunk/LayoutTests/fast/canvas/script-tests/canvas-color-serialization.js
r98407 r170933 231 231 trySettingColor("Infinity", "'#666666'"); 232 232 trySettingColor("null", "'#666666'"); 233 trySettingColor("'left'", "'#666666'"); 234 trySettingColor("'right'", "'#666666'"); 235 trySettingColor("'center'", "'#666666'"); 236 trySettingColor("'border'", "'#666666'"); 237 trySettingColor("'border-box'", "'#666666'"); 238 trySettingColor("'content'", "'#666666'"); 239 trySettingColor("'logical'", "'#666666'"); 240 trySettingColor("'visual'", "'#666666'"); 233 241 234 242 trySettingColorWithSetter("'transparent'", "'rgba(0, 0, 0, 0)'"); -
trunk/LayoutTests/fast/css/test-setting-canvas-color-expected.txt
r78442 r170933 215 215 PASS Setting color to #100px was not set (as expected). 216 216 PASS Setting color to -webkit-var("test") was not set (as expected). 217 PASS Setting color to left was not set (as expected). 218 PASS Setting color to right was not set (as expected). 219 PASS Setting color to center was not set (as expected). 220 PASS Setting color to border was not set (as expected). 221 PASS Setting color to border was not set (as expected). 222 PASS Setting color to content was not set (as expected). 223 PASS Setting color to logical was not set (as expected). 224 PASS Setting color to visual was not set (as expected). 217 225 PASS successfullyParsed is true 218 226 -
trunk/LayoutTests/fast/css/test-setting-canvas-color.html
r155263 r170933 243 243 shouldNotSuccessfullyParse("#100px"); 244 244 shouldNotSuccessfullyParse('-webkit-var("test")'); 245 shouldNotSuccessfullyParse('left'); 246 shouldNotSuccessfullyParse('right'); 247 shouldNotSuccessfullyParse('center'); 248 shouldNotSuccessfullyParse('border'); 249 shouldNotSuccessfullyParse('border'); 250 shouldNotSuccessfullyParse('content'); 251 shouldNotSuccessfullyParse('logical'); 252 shouldNotSuccessfullyParse('visual'); 245 253 </script> 246 254 <script src="../../resources/js-test-post.js"></script> -
trunk/LayoutTests/svg/dom/rgb-color-parser-expected.txt
r99757 r170933 6 6 Parsed as rgb(0,0,255): blue 7 7 Parsed as rgb(0,255,0): rgb(0, 255, 0) 8 Parsed as rgb(240,248,255): aliceblue 9 Parsed as rgb(250,235,215): antiquewhite 10 Parsed as rgb(0,255,255): aqua 11 Parsed as rgb(127,255,212): aquamarine 12 Parsed as rgb(240,255,255): azure 13 Parsed as rgb(245,245,220): beige 14 Parsed as rgb(255,228,196): bisque 15 Parsed as rgb(0,0,0): black 16 Parsed as rgb(255,235,205): blanchedalmond 17 Parsed as rgb(0,0,255): blue 18 Parsed as rgb(138,43,226): blueviolet 19 Parsed as rgb(165,42,42): brown 20 Parsed as rgb(222,184,135): burlywood 21 Parsed as rgb(95,158,160): cadetblue 22 Parsed as rgb(127,255,0): chartreuse 23 Parsed as rgb(210,105,30): chocolate 24 Parsed as rgb(255,127,80): coral 25 Parsed as rgb(100,149,237): cornflowerblue 26 Parsed as rgb(255,248,220): cornsilk 27 Parsed as rgb(220,20,60): crimson 28 Parsed as rgb(0,255,255): cyan 29 Parsed as rgb(0,0,139): darkblue 30 Parsed as rgb(0,139,139): darkcyan 31 Parsed as rgb(184,134,11): darkgoldenrod 32 Parsed as rgb(169,169,169): darkgray 33 Parsed as rgb(0,100,0): darkgreen 34 Parsed as rgb(169,169,169): darkgrey 35 Parsed as rgb(189,183,107): darkkhaki 36 Parsed as rgb(139,0,139): darkmagenta 37 Parsed as rgb(85,107,47): darkolivegreen 38 Parsed as rgb(255,140,0): darkorange 39 Parsed as rgb(153,50,204): darkorchid 40 Parsed as rgb(139,0,0): darkred 41 Parsed as rgb(233,150,122): darksalmon 42 Parsed as rgb(143,188,143): darkseagreen 43 Parsed as rgb(72,61,139): darkslateblue 44 Parsed as rgb(47,79,79): darkslategray 45 Parsed as rgb(47,79,79): darkslategrey 46 Parsed as rgb(0,206,209): darkturquoise 47 Parsed as rgb(148,0,211): darkviolet 48 Parsed as rgb(255,20,147): deeppink 49 Parsed as rgb(0,191,255): deepskyblue 50 Parsed as rgb(105,105,105): dimgray 51 Parsed as rgb(105,105,105): dimgrey 52 Parsed as rgb(30,144,255): dodgerblue 53 Parsed as rgb(178,34,34): firebrick 54 Parsed as rgb(255,250,240): floralwhite 55 Parsed as rgb(34,139,34): forestgreen 56 Parsed as rgb(255,0,255): fuchsia 57 Parsed as rgb(220,220,220): gainsboro 58 Parsed as rgb(248,248,255): ghostwhite 59 Parsed as rgb(255,215,0): gold 60 Parsed as rgb(218,165,32): goldenrod 61 Parsed as rgb(128,128,128): gray 62 Parsed as rgb(0,128,0): green 63 Parsed as rgb(173,255,47): greenyellow 64 Parsed as rgb(128,128,128): grey 65 Parsed as rgb(240,255,240): honeydew 66 Parsed as rgb(255,105,180): hotpink 67 Parsed as rgb(205,92,92): indianred 68 Parsed as rgb(75,0,130): indigo 69 Parsed as rgb(255,255,240): ivory 70 Parsed as rgb(240,230,140): khaki 71 Parsed as rgb(230,230,250): lavender 72 Parsed as rgb(255,240,245): lavenderblush 73 Parsed as rgb(124,252,0): lawngreen 74 Parsed as rgb(255,250,205): lemonchiffon 75 Parsed as rgb(173,216,230): lightblue 76 Parsed as rgb(240,128,128): lightcoral 77 Parsed as rgb(224,255,255): lightcyan 78 Parsed as rgb(250,250,210): lightgoldenrodyellow 79 Parsed as rgb(211,211,211): lightgray 80 Parsed as rgb(144,238,144): lightgreen 81 Parsed as rgb(211,211,211): lightgrey 82 Parsed as rgb(255,182,193): lightpink 83 Parsed as rgb(255,160,122): lightsalmon 84 Parsed as rgb(32,178,170): lightseagreen 85 Parsed as rgb(135,206,250): lightskyblue 86 Parsed as rgb(119,136,153): lightslategray 87 Parsed as rgb(119,136,153): lightslategrey 88 Parsed as rgb(176,196,222): lightsteelblue 89 Parsed as rgb(255,255,224): lightyellow 90 Parsed as rgb(0,255,0): lime 91 Parsed as rgb(50,205,50): limegreen 92 Parsed as rgb(250,240,230): linen 93 Parsed as rgb(255,0,255): magenta 94 Parsed as rgb(128,0,0): maroon 95 Parsed as rgb(102,205,170): mediumaquamarine 96 Parsed as rgb(0,0,205): mediumblue 97 Parsed as rgb(186,85,211): mediumorchid 98 Parsed as rgb(147,112,219): mediumpurple 99 Parsed as rgb(60,179,113): mediumseagreen 100 Parsed as rgb(123,104,238): mediumslateblue 101 Parsed as rgb(0,250,154): mediumspringgreen 102 Parsed as rgb(72,209,204): mediumturquoise 103 Parsed as rgb(199,21,133): mediumvioletred 104 Parsed as rgb(25,25,112): midnightblue 105 Parsed as rgb(245,255,250): mintcream 106 Parsed as rgb(255,228,225): mistyrose 107 Parsed as rgb(255,228,181): moccasin 108 Parsed as rgb(255,222,173): navajowhite 109 Parsed as rgb(0,0,128): navy 110 Parsed as rgb(253,245,230): oldlace 111 Parsed as rgb(128,128,0): olive 112 Parsed as rgb(107,142,35): olivedrab 113 Parsed as rgb(255,165,0): orange 114 Parsed as rgb(255,69,0): orangered 115 Parsed as rgb(218,112,214): orchid 116 Parsed as rgb(238,232,170): palegoldenrod 117 Parsed as rgb(152,251,152): palegreen 118 Parsed as rgb(175,238,238): paleturquoise 119 Parsed as rgb(219,112,147): palevioletred 120 Parsed as rgb(255,239,213): papayawhip 121 Parsed as rgb(255,218,185): peachpuff 122 Parsed as rgb(205,133,63): peru 123 Parsed as rgb(255,192,203): pink 124 Parsed as rgb(221,160,221): plum 125 Parsed as rgb(176,224,230): powderblue 126 Parsed as rgb(128,0,128): purple 127 Parsed as rgb(188,143,143): rosybrown 128 Parsed as rgb(65,105,225): royalblue 129 Parsed as rgb(139,69,19): saddlebrown 130 Parsed as rgb(250,128,114): salmon 131 Parsed as rgb(244,164,96): sandybrown 132 Parsed as rgb(46,139,87): seagreen 133 Parsed as rgb(255,245,238): seashell 134 Parsed as rgb(160,82,45): sienna 135 Parsed as rgb(192,192,192): silver 136 Parsed as rgb(135,206,235): skyblue 137 Parsed as rgb(106,90,205): slateblue 138 Parsed as rgb(112,128,144): slategray 139 Parsed as rgb(112,128,144): slategrey 140 Parsed as rgb(255,250,250): snow 141 Parsed as rgb(0,255,127): springgreen 142 Parsed as rgb(70,130,180): steelblue 143 Parsed as rgb(210,180,140): tan 144 Parsed as rgb(0,128,128): teal 145 Parsed as rgb(216,191,216): thistle 146 Parsed as rgb(255,99,71): tomato 147 Parsed as rgb(64,224,208): turquoise 148 Parsed as rgb(238,130,238): violet 149 Parsed as rgb(245,222,179): wheat 150 Parsed as rgb(255,255,255): white 151 Parsed as rgb(245,245,245): whitesmoke 152 Parsed as rgb(255,255,0): yellow 153 Parsed as rgb(154,205,50): yellowgreen 8 154 Failed to parse: rgb(100%,100%,0% 9 155 Failed to parse: rgba(100%,100%,0% … … 22 168 Failed to parse: #fffffff 23 169 Failed to parse: green, 170 Failed to parse: 'left' 171 Failed to parse: 'right' 172 Failed to parse: 'center' 173 Failed to parse: 'border' 174 Failed to parse: 'border- 175 Failed to parse: 'content' 176 Failed to parse: 'logical' 177 Failed to parse: 'visual' 24 178 Parsed as rgb(0,10,20): rgb(0, 10, 20) 25 179 Parsed as rgb(255,255,255): #fff -
trunk/LayoutTests/svg/dom/rgb-color-parser.html
r155284 r170933 55 55 } 56 56 57 // Taken from CSS 3 color. 58 var svgColors = [ 59 "aliceblue", 60 "antiquewhite", 61 "aqua", 62 "aquamarine", 63 "azure", 64 "beige", 65 "bisque", 66 "black", 67 "blanchedalmond", 68 "blue", 69 "blueviolet", 70 "brown", 71 "burlywood", 72 "cadetblue", 73 "chartreuse", 74 "chocolate", 75 "coral", 76 "cornflowerblue", 77 "cornsilk", 78 "crimson", 79 "cyan", 80 "darkblue", 81 "darkcyan", 82 "darkgoldenrod", 83 "darkgray", 84 "darkgreen", 85 "darkgrey", 86 "darkkhaki", 87 "darkmagenta", 88 "darkolivegreen", 89 "darkorange", 90 "darkorchid", 91 "darkred", 92 "darksalmon", 93 "darkseagreen", 94 "darkslateblue", 95 "darkslategray", 96 "darkslategrey", 97 "darkturquoise", 98 "darkviolet", 99 "deeppink", 100 "deepskyblue", 101 "dimgray", 102 "dimgrey", 103 "dodgerblue", 104 "firebrick", 105 "floralwhite", 106 "forestgreen", 107 "fuchsia", 108 "gainsboro", 109 "ghostwhite", 110 "gold", 111 "goldenrod", 112 "gray", 113 "green", 114 "greenyellow", 115 "grey", 116 "honeydew", 117 "hotpink", 118 "indianred", 119 "indigo", 120 "ivory", 121 "khaki", 122 "lavender", 123 "lavenderblush", 124 "lawngreen", 125 "lemonchiffon", 126 "lightblue", 127 "lightcoral", 128 "lightcyan", 129 "lightgoldenrodyellow", 130 "lightgray", 131 "lightgreen", 132 "lightgrey", 133 "lightpink", 134 "lightsalmon", 135 "lightseagreen", 136 "lightskyblue", 137 "lightslategray", 138 "lightslategrey", 139 "lightsteelblue", 140 "lightyellow", 141 "lime", 142 "limegreen", 143 "linen", 144 "magenta", 145 "maroon", 146 "mediumaquamarine", 147 "mediumblue", 148 "mediumorchid", 149 "mediumpurple", 150 "mediumseagreen", 151 "mediumslateblue", 152 "mediumspringgreen", 153 "mediumturquoise", 154 "mediumvioletred", 155 "midnightblue", 156 "mintcream", 157 "mistyrose", 158 "moccasin", 159 "navajowhite", 160 "navy", 161 "oldlace", 162 "olive", 163 "olivedrab", 164 "orange", 165 "orangered", 166 "orchid", 167 "palegoldenrod", 168 "palegreen", 169 "paleturquoise", 170 "palevioletred", 171 "papayawhip", 172 "peachpuff", 173 "peru", 174 "pink", 175 "plum", 176 "powderblue", 177 "purple", 178 // We do not test red. 179 "rosybrown", 180 "royalblue", 181 "saddlebrown", 182 "salmon", 183 "sandybrown", 184 "seagreen", 185 "seashell", 186 "sienna", 187 "silver", 188 "skyblue", 189 "slateblue", 190 "slategray", 191 "slategrey", 192 "snow", 193 "springgreen", 194 "steelblue", 195 "tan", 196 "teal", 197 "thistle", 198 "tomato", 199 "turquoise", 200 "violet", 201 "wheat", 202 "white", 203 "whitesmoke", 204 "yellow", 205 "yellowgreen" 206 ]; 207 57 208 function fuzz() 58 209 { … … 60 211 parseRGBColor("blue"); 61 212 parseRGBColor("rgb(0, 255, 0)"); 62 213 for (var i = 0; i < svgColors.length; ++i) 214 parseRGBColor(svgColors[i]); 215 63 216 // Some invalid ones. 64 217 parseRGBColor("rgb(100%,100%,0%"); … … 78 231 parseRGBColor("#fffffff"); 79 232 parseRGBColor("green,"); 233 parseRGBColor("'left'"); 234 parseRGBColor("'right'"); 235 parseRGBColor("'center'"); 236 parseRGBColor("'border'"); 237 parseRGBColor("'border-"); 238 parseRGBColor("'content'"); 239 parseRGBColor("'logical'"); 240 parseRGBColor("'visual'"); 80 241 81 242 // Some more valid ones. -
trunk/Source/WebCore/ChangeLog
r170932 r170933 1 2014-07-09 Javier Fernandez <jfernandez@igalia.com> 2 CSS canvas color parsing accepts invalid color identifiers 3 https://bugs.webkit.org/show_bug.cgi?id=134661 4 5 Reviewed by Benjamin Poulain. 6 7 Current implementation of the CSSParser::parseSystemColor assumes 8 that if a valid cssValueKeywordID is got then it has to be a valid 9 color. Such assumption is wrong and lead to many bugs and layout 10 test failures. 11 12 The parseSystemFunction determines now whether the parsed color is 13 valid or not. 14 15 Addtionally, a new method has been added to share the logic of 16 determining whether a CSSValueID is a valid primitive values for 17 colors or not. Generally, we should avoid passing invalid color 18 identifiers to the theming API. 19 20 No new tests, but added additional cases to the 21 canvas-color-serialization.html, test-setting-canvas-color and 22 rgb-color-parse test. 23 24 * css/CSSParser.cpp: 25 (WebCore::validPrimitiveValueColor): Added. 26 (WebCore::parseColorValue): 27 (WebCore::CSSParser::parseSystemColor): 28 1 29 2014-06-28 Jer Noble <jer.noble@apple.com> 2 30 -
trunk/Source/WebCore/css/CSSParser.cpp
r170774 r170933 502 502 } 503 503 504 static bool validPrimitiveValueColor(CSSValueID valueID, bool strict = false) 505 { 506 return (valueID == CSSValueWebkitText || valueID == CSSValueCurrentcolor || valueID == CSSValueMenu 507 || (valueID >= CSSValueAlpha && valueID <= CSSValueWindowtext) 508 || (valueID >= CSSValueWebkitFocusRingColor && valueID < CSSValueWebkitText && !strict)); 509 } 510 504 511 static bool parseColorValue(MutableStyleProperties* declaration, CSSPropertyID propertyId, const String& string, bool important, CSSParserMode cssParserMode) 505 512 { … … 511 518 cssString.init(string); 512 519 CSSValueID valueID = cssValueKeywordID(cssString); 513 bool validPrimitive = false; 514 if (valueID == CSSValueWebkitText) 515 validPrimitive = true; 516 else if (valueID == CSSValueCurrentcolor) 517 validPrimitive = true; 518 else if ((valueID >= CSSValueAqua && valueID <= CSSValueWindowtext) || valueID == CSSValueMenu 519 || (valueID >= CSSValueWebkitFocusRingColor && valueID < CSSValueWebkitText && !strict)) { 520 validPrimitive = true; 521 } 522 523 if (validPrimitive) { 520 if (validPrimitiveValueColor(valueID, strict)) { 524 521 RefPtr<CSSValue> value = cssValuePool().createIdentifierValue(valueID); 525 522 declaration->addParsedProperty(CSSProperty(propertyId, value.release(), important)); … … 1356 1353 cssColor.init(string); 1357 1354 CSSValueID id = cssValueKeywordID(cssColor); 1358 if (id <= 0) 1359 return false; 1360 1361 color = document->page()->theme().systemColor(id).rgb(); 1355 if (!validPrimitiveValueColor(id)) 1356 return false; 1357 1358 Color parsedColor = document->page()->theme().systemColor(id); 1359 if (!parsedColor.isValid()) 1360 return false; 1361 1362 color = parsedColor.rgb(); 1362 1363 return true; 1363 1364 }
Note: See TracChangeset
for help on using the changeset viewer.