This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 12372 - Rules for parsing a legacy color value should strip whitespace
Summary: Rules for parsing a legacy color value should strip whitespace
Status: CLOSED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: LC1 HTML5 spec (show other bugs)
Version: unspecified
Hardware: All All
: P2 minor
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-24 17:55 UTC by Aryeh Gregor
Modified: 2011-08-04 05:06 UTC (History)
4 users (show)

See Also:


Attachments

Description Aryeh Gregor 2011-03-24 17:55:02 UTC
Consider the legacy color value " #fff".  The spec doesn't strip the whitespace from input, only from keyword, so it fails to remove the leading space and doesn't treat the # specially.  Then it replaces all non-hex characters by "0", so it gets "00fff".  Then it's not a multiple of three, so it pads to "00fff0".  This translates to #00fff0, a.k.a. rgb(0, 255, 240).  Likewise, " fff" becomes "0fff00".  Test case:

<!doctype html>
<font color=" #fff">Test</font>
<font color="#fff">Test</font>
<font color=" fff">Test</font>
<font color="fff">Test</font>
<script>document.body.textContent =
getComputedStyle(document.querySelectorAll("font")[0]).color
+ getComputedStyle(document.querySelectorAll("font")[1]).color
+ getComputedStyle(document.querySelectorAll("font")[2]).color
+ getComputedStyle(document.querySelectorAll("font")[3]).color;</script>

Spec:          #00fff0#ffffff#0fff00#0f0f0f
IE 9 RC:       #0f0f0f#0f0f0f#0f0f0f#0f0f0f
Firefox 4 RC:  #ffffff#ffffff#0f0f0f#0f0f0f
Chrome 11 dev: #ffffff#ffffff#ffffff#ffffff
Opera 11:      #0fff00#0f0f0f#0f0f0f#0f0f0f

(I've translated rgb() syntax to hex for easier interpretation.)  If the spec stripped whitespace, it would be:

               #ffffff#ffffff#0f0f0f#0f0f0f

which exactly matches Gecko.  The current spec doesn't match any browser for the leading-whitespace cases, while this change would make it match two or three browsers respectively.
Comment 1 Ian 'Hixie' Hickson 2011-05-08 00:39:18 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale: Concurred with reporter's comments.
Comment 2 contributor 2011-05-08 00:39:43 UTC
Checked in as WHATWG revision r6123.
Check-in comment: Looks like whitespace stripping needs to happen to non-keywords too.
http://html5.org/tools/web-apps-tracker?from=6122&to=6123
Comment 3 Ian 'Hixie' Hickson 2011-05-08 00:40:06 UTC
BTW, see bug 9847 and r5359 for history.
Comment 4 Michael[tm] Smith 2011-08-04 05:06:23 UTC
mass-moved component to LC1