W3C home > Mailing lists > Public > www-html@w3.org > September 2001

ampersands as literal characters in a URL?

From: <Tony.Rees@csiro.au>
Date: Wed, 26 Sep 2001 01:14:54 -0400 (EDT)
Message-ID: <576A86EC05E22742A26B1D742DE7529238F421@molly.tas.csiro.au>
To: www-html@w3.org
Hi all,

Maybe somebody can help me. I have some HTML documents which I am trying to
validate against HTML 4.01 using the HTML validator on the W3 site. I can
resolve all problems apart from the use of the ampersand character (&)
within a URL where it performs a function to concatenate parameters which
are being sent to a CGI script or (in my case) an Oracle PL/SQL procedure.

This type of expression is detailed in appendix B to the HTML 4
specification at http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.2 , as
follows:

"B.2.2 Ampersands in URI attribute values

         The URI that is constructed when a form is submitted may be used as
an anchor-style link (e.g., the href attribute for the A element).
         Unfortunately, the use of the "&" character to separate form fields
interacts with its use in SGML attribute values to delimit character
         entity references. For example, to use the URI
"http://host/?x=1&y=2" as a linking URI, it must be written <A
         href="http://host/?x=1&#38;y=2"> or <A
href="http://host/?x=1&amp;y=2">  "

The only trouble is, neither of these solutions work! My PL/SQL procedures
return an Oracle error message (OWS-05101: Execution failed due to Oracle
error -6550) when I attempt to replace the ampersand in a URL with either
&#38; or &amp; . Neither does it work when I try the hex equivalent, %26.

This problem is likely to be widespread, for example the search box on this
list's own archives uses a URL of the type

http://search.w3.org/Public/cgi-bin/query?mss=simple&pg=q&what=web&filter=li
sts&fmt=.&q=ampersand+URL&search=Search

which is full of ampersands...

So, if (as it appears) that URLs of this type will always cause the current
validation to fail, and the ampersands cannot be replaced with anything else
which will work with the CGI or PL/SQL scripts, isn't there a case for the
HTML spec to be modified to permit the use of ampersands within the <A
HREF></A> tags? Or, is there another solution I am not aware of?

Any assistance/response from the authors of HTML 4.01 would be appreciated.

Thanks in advance,

Tony Rees
Hobart, Tasmania (Australia)
Received on Friday, 28 September 2001 04:23:26 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:49 GMT