[Zope3-dev] Re: [Nuxeo-checkins] r30260 - in CPSSkins/trunk:
. skins/cpsskins_cmf
Jean-Marc Orliaguet
jmo at ita.chalmers.se
Sun Dec 4 12:59:07 EST 2005
Jean-Marc Orliaguet wrote:
> Florent Guillaume wrote:
>
>> Redirecting to a relative url is illegal in the HTTP spec. You must
>> always use a fully qualified url.
>>
>> Florent
>>
>>> + redirect_url = REQUEST['HTTP_REFERER'] or '.'
>>> + RESPONSE.redirect(redirect_url)
>>
>>
>
> OK, but can you raise that one zope3-dev? It is used all over the
> place in the zope3 code as a standard way or doing redirection, just
> do a grep on:
>
> $ grep -r response.redirect Zope3/src
>
> I checked the redirect() method in publisher/http.py and it just sets
> the Location to what it is told to ('.', 'somemethod.html')
>
> /JM
>
OK, that's the one in Zope3/src/zope/publisher/browser.py that is used...
def redirect(self, location, status=None):
base = getattr(self, '_base', '')
if base and isRelative(str(location)):
l = base.rfind('/')
if l >= 0:
base = base[:l+1]
else:
base += '/'
location = base + location
# TODO: HTTP redirects must provide an absolute location, see
#
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30
# So, what if location is relative and base is unknown?
Uncomment
# the following and you'll see that it actually happens.
#
# if isRelative(str(location)):
# raise AssertionError('Cannot determine absolute location')
return super(BrowserResponse, self).redirect(location, status)
/JM
More information about the Zope3-dev
mailing list