W3C home > Mailing lists > Public > www-validator@w3.org > February 2005

Ampersands in the HTTP Header

From: Richard Neill <rn214@hermes.cam.ac.uk>
Date: Fri, 25 Feb 2005 02:27:10 +0000
Message-ID: <421E8CFE.4020501@hermes.cam.ac.uk>
To: www-validator@w3.org

Dear Validator,

I read your page on Ampersands in URLs, and duly arranged all my
URLs to be like this:

<a href="http://www.example.com/index.php?foo=bar&amp;baz=wombat"> link</a>

So far, so good. BUT, if one does the same thing with HTTP headers, eg 
this fragment of PHP:

header("Location: $redirect_location");

then it will fail. It is necessary (tested in both Konqueror and 
Mozilla) to use '&' , NOT '&amp;' in this case. Otherwise, the '&amp;' 
is not evaluated, and the index.php script does not get to know the 
value of baz.

So, I think 3 things arise:

1)Is this a bug in Moz/Konqui, or is it a bug in the various 
documentations (which don't mention this exception)?

2)If I feed the validator with a page containing the above PHP fragment, 
it goes on to validate the page that it is redirected to. It doesn't 
complain about the page that is doing the redirecting, whether I use '&' 
or '&amp;'. Perhaps it should?

3)Why is the behaviour different in an HTTP header than in a link?



P.S. I'm not subscribed to this list, so please CC me.

rn214@hermes.cam.ac.uk  **  http://www.richardneill.org
Richard Neill, Trinity College, Cambridge, CB21TQ, U.K.
Received on Friday, 25 February 2005 03:06:55 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 14:17:44 UTC