Re: [CSS21] Unquoted url() syntax

On Tue, Dec 18, 2012 at 1:33 PM, Shawn Ligocki <sligocki@google.com> wrote:
> Tokenization for unquoted url()s doesn't makes sense to me (from
> http://www.w3.org/TR/CSS21/syndata.html#tokenization):
>
> url\({w}([!#$%&*-\[\]-~]|{nonascii}|{escape})*{w}\)
>
> Specifically, [!#$%&*-\[\]-~] confuses me. Is it meant to be
> [^!#$%&*-\[\]-~]  (that is, all chars except !#$%&*-[]~ )? (Also note that
> '-' is listed twice, is that significant or a typo?)

Note that a - in a non-initial or non-final position of a character
class does *not* represent a dash - it indicates a character range.
Both uses of - in that regex are ranges.  They're very awkward ranges,
of course.  The end result is that that character class matches all
the ascii characters that are valid in urls.

> For some context, I am trying to to automatically generate CSS files and I
> want to know which chars need to be escaped in unquoted url()s.
> Specifically, are unescaped strings allowed? Both Chrome and Firefox do not
> appear to allow spaces in unquoted url()s, but I can't tell what part of the
> spec is precluding this.
>
> Perhaps they are implementing CSS3 (from
> http://www.w3.org/TR/css3-syntax/#tokenization):
>
> urlchar ::= [#x9#x21#x23-#x26#x27-#x7E] | nonascii | escape
>
> where space #x20 is not allowed? This spec is also confusing, does
> #x23-#x26#x27-#x7E mean the same thing as #x23-#x7E? That is all chars from
> '!' to '~' inclusive? Or is it a typo and #27 '\'' was meant to be excluded?

Ignore that draft forever; I'll burn it to the ground as soon as I
can.  My completely rewritten Syntax draft at
<http://dev.w3.org/csswg/css3-syntax> is much more reliable.  Once
I've convince the group that it's sufficiently correct, it'll replace
that dreadfully obsolete and incorrect draft currently on /TR.

My Syntax draft is also much easier to understand than that regex.
Here's the url-unquoted state
<http://dev.w3.org/csswg/css3-syntax/#url-unquoted-state> which shows
pretty clearly which characters have to be escaped (they're the ones
that switch out of this state).

~TJ

Received on Tuesday, 18 December 2012 21:52:23 UTC