- From: Zack Weinberg <zweinberg@mozilla.com>
- Date: Fri, 26 Sep 2008 17:23:58 -0700
- To: "Linss, Peter" <peter.linss@hp.com>, W3C Emailing list for WWW Style <www-style@w3.org>
- Message-ID: <20080926172358.0c80fade@mrtock.san.rr.com>
"Linss, Peter" <peter.linss@hp.com> wrote: [...] > This literally means that comments can appear anywhere (except within > a token) [...] > Where this gets interesting is that both 4.1.1 and Appendix G.2 define > "url(http://example.com/)" as a single token, which means that > comments are not allowed within. Right. Everything I said presumed that, as url(...) is one token, the only way comments could be allowed within was if the lexical rules explicitly said so. > I know that Gecko tokenizes this as > three separate tokens: "url(", "http://example.com/", and ")"; a > FUNCTION token, a URL token and a symbol token. Yes. And, at present, it allows comments in between those three tokens under some circumstances, but not all the things that could be read as comments are. I'm pretty sure the current behavior is not desirable, but before I go touching it at all I want to be sure what we ought to be doing. I'm attaching a probe of the behavior of comments within url(). I can only easily test with Gecko (3.0 and trunk), Linux Opera 9.52, and Windows IE 7.0.6001.18000. Their behavior is: Gecko: Comments are allowed on either side of a quoted URL. Comments are also allowed before an unquoted URL, but only if there is a space between the comment and the URL. Opera: No comments are allowed within the parentheses. IE7: Comments are allowed except where they follow an unquoted URL with no intervening spaces. The HTML file relies on two external files, allowed.gif and forbidden.gif (also attached) - these are just green and red single pixels. I don't use data: URLs because I am curious what happens in old browsers that don't support that. In the test, cells where the background color is green are cases where comments are allowed (that is, the uri-token quoted resolves to "allowed.gif"); if the background is any other color, comments are not allowed in that case. Some cases will be red and others white - all browsers seem to make a distinction between "this is nonsense, I'm falling back to the less specific rule" (red) and "that uri-token resolves to a file that doesn't exist, so you get no background image at all" (white). > It could be relatively safe to allow comments within a url() function > so long as there is whitespace between the comment and the URL part > (unless the URL is quoted), something like: > > {U}{R}{L}"("({w}|{comment})*{string}({w}|{comment})*")" > {return URI;} > {U}{R}{L}"("{w}({comment}{s})*{url}({s}{comment})*{w}")" > {return URI;} I'm not eager to match IE in this case; I'd be fine with your proposal or with allowing comments only in quoted URLs; I would rather not forbid comments in conjunction with quoted URLs. zw
Attachments
- text/html attachment: url-comments.html
- image/gif attachment: allowed.gif
- image/gif attachment: forbidden.gif
Received on Saturday, 27 September 2008 00:24:45 UTC