[Bug 12372] New: Rules for parsing a legacy color value should strip whitespace or something

http://www.w3.org/Bugs/Public/show_bug.cgi?id=12372

           Summary: Rules for parsing a legacy color value should strip
                    whitespace or something
           Product: HTML WG
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: HTML5 spec (editor: Ian Hickson)
        AssignedTo: ian@hixie.ch
        ReportedBy: Simetrical+w3cbug@gmail.com
         QAContact: public-html-bugzilla@w3.org
                CC: mike@w3.org, public-html-wg-issue-tracking@w3.org,
                    public-html@w3.org


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.

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Received on Thursday, 24 March 2011 17:55:05 UTC