W3C home > Mailing lists > Public > www-style@w3.org > September 1996

Re: Right paren in urls

From: Bert Bos <bbos@mygale.inria.fr>
Date: Mon, 9 Sep 1996 14:35:41 +0200 (MET DST)
Message-Id: <199609091235.OAA10485@mygale.inria.fr>
To: jrd@netcom.com
Cc: www-style@w3.org
Jon Degenhardt writes:
 > A minor syntax question: What are the legal ways specify urls containing
 > right
 > parentheses? Right parentheses are "safe" characters in urls and don't
 > need
 > to encoded, but they are also the termination character in style sheet
 > url
 > references. 
 > 
 > My guess is that unencoded right parens would be legal in quoted urls,
 > and
 > illegal in unquoted urls. For example:
 > 
 >    Legal:    BODY { background: url("right)paren.gif") }
 >    Legal:    BODY { background: url('right)paren.gif') }
 >    Illegal:  BODY { background: url(right)paren.gif) }
 > 
 > However, this isn't clear to me from the style sheet specs. The lex
 > grammar
 > in Appendix B of 7/26/96 CSS-1 Working Draft doesn't handle any of these
 > cases.
 > This suggests all three forms may be illegal. The lex form from the
 > draft is:
 > 
 >    "url("[^\n)]+")"        {yylval.str = noquotes(yytext+3); return
 > URL;}
 > 
 > This terminates the url at the first right paren, in a quoted string or
 > not.

Good point. The Lex expression is indeed wrong.

The safe way to use a literal parenthesis, in a URL or elsewhere, is
to escape it with a backslash. Section 7.2 ("parsing conventions")
explains that any character can be escaped with a backslash to remove
its special meaning. The way to write the URL is thus:

    BODY { background: url(right\)paren.gif) }

and the Lex rule should be:

    "url("([^\n)]|{escape})+")"

I must admit we didn't think of putting quotes around URLs that are
already inside parentheses. Quotes do remove the special meaning of
parentheses, so maybe we should indeed allow

    BODY { background: url("right)paren.gif") }
    BODY { background: url('right)paren.gif') }

as well. Have to think about that one...



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/pub/WWW/People/Bos/                      INRIA/W3C
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 93 65 77 71                 06902 Sophia Antipolis Cedex, France
Received on Monday, 9 September 1996 08:36:11 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:53:45 GMT