[Zope] RESPONSE.redirect(to a subanchor#everything behind disappears)

Dieter Maurer dieter@handshake.de
Wed, 19 Sep 2001 18:41:13 +0200 (CEST)


Hannes Wyss writes:
 > For a form-evaluation i want to redirect the user back to the form in 
 > case there is input missing.
 > 
 > this is what I try:
 > 
 > <pre>
 > <dtml-call "RESPONSE.redirect('some_url?foo=some&bar=vars#subanchor')">
 > </pre>
 > 
 > and this is what i get:
 > some_url?foo=some&bar=vars
 > 
 > annoying! I have concluded (knowing very little about Python), that 
 > somewhere within the Python-Part of the redirect method the tail of my 
 > url is interpreted as a comment. The Python documentation states, that # 
 > is indeed the start of a comment, unless it is part of a string literal.
Your conclusion is wrong.

  Indeed you need nothing to know about Python but about
  URLs (RFC 2396) and HTTP 1.1 (RFC 2616).

  As of RFC 2396, the fragment (your '#subanchor') is not part of an URL
  but only of an URL reference.

  As of RFC 2616, the "Location" header (used for redirects)
  must be an absolute URI, especially an URI and not
  an URI reference. A fragment is not allowed.

  Almost surely, the fragment is stripped by your browser.

With respect to Python: inside a string (e.g. something enclosed in
'...'), '#' does not start a comment but is part of the string.
  


Dieter