Re: Ampersands in URLs: Validator conflicts with RFC2396?

On Wed, 23 Oct 2002, Maarten de Boer wrote:
>
> The w3c validator tells me about the invalid use of an & in a
> URI, just as described in the FAQ.
> 
> http://www.htmlhelp.com/tools/validator/problems.html#amp
> 
> However, I find this explanation rather dubious, when I compare it
> to the "Uniform Resource Identifiers (URI): Generic Syntax" RFC2396

The error has absolutely nothing to do with RFC2396. Using ampersands
anywhere in HTML requires them to be escaped, since & means something
special _to HTML_.

For example:

   <abbr title="Dungeons&Dragons">

...is invalid, because the & implies that the next word (Dragons) is an
entity, which isn't the case.

Instead it has to be written as:

   <abbr title="Dungeons&amp;Dragons">   

It's just that ampersands occur in URIs more often, so the error is hit
more often in the context of URIs.

The problem is most obvious if the text after the & character is something
like "gt", as in:

   foo&gt

...because that is then EXACTLY equivalent to:

   foo>

...which is not the same as:

   foo&amp;gt

HTH,
-- 
Ian Hickson                                      )\._.,--....,'``.    fL
"meow"                                          /,   _.. \   _\  ;`._ ,.
http://index.hixie.ch/                         `._.-(,_..'--(,_..'`-.;.'

Received on Wednesday, 23 October 2002 20:35:07 UTC