From: dman13 Date: Fri, 14 Jun 2002 01:25:46 +0000 (+0000) Subject: Fixed bug #558867 by redirecting /instance requests to /instance/ X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=cea4e65285e87c9fdfdeeb6ae82b3ca1ba1faad7;p=roundup.git Fixed bug #558867 by redirecting /instance requests to /instance/ git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@781 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index 13ec273..cefb216 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -40,6 +40,7 @@ Feature: - also changed cgi client since it was duplicating the functionality Fixed: + . #558867 ] ZRoundup redirect /instance requests to /instance/ . #562130 ] cookie path generated from ZRoundup was wrong in some situations . stop sending blank (whitespace-only) notes . cleanup of serialisation for database storage diff --git a/frontends/ZRoundup/ZRoundup.py b/frontends/ZRoundup/ZRoundup.py index 371719d..8cd92ab 100644 --- a/frontends/ZRoundup/ZRoundup.py +++ b/frontends/ZRoundup/ZRoundup.py @@ -14,7 +14,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: ZRoundup.py,v 1.6 2002-06-12 00:59:44 dman13 Exp $ +# $Id: ZRoundup.py,v 1.7 2002-06-14 01:25:46 dman13 Exp $ # ''' ZRoundup module - exposes the roundup web interface to Zope @@ -32,6 +32,9 @@ _must_ be done using a GET, so that this interface can re-parse the QUERY_STRING. Zope interprets the ':' as a special character, and the special args are lost to it. ''' + +import urlparse + from Globals import InitializeClass, HTMLFile from OFS.SimpleItem import Item from OFS.PropertyManager import PropertyManager @@ -125,9 +128,8 @@ class ZRoundup(Item, PropertyManager, Implicit, Persistent): env = self.REQUEST.environ # figure out the path components to set - import urlparse - path = urlparse.urlparse( self.absolute_url() )[2] - path_components = path.split( '/' ) + url = urlparse.urlparse( self.absolute_url() ) + path_components = url[2].split( '/' ) # special case when roundup is '/' in this virtual host, if path == "/" : @@ -138,7 +140,6 @@ class ZRoundup(Item, PropertyManager, Implicit, Persistent): env['SCRIPT_NAME'] = '/'.join( path_components[:-1] ) # the last element is the name env['INSTANCE_NAME'] = path_components[-1] - del path_components , path if env['REQUEST_METHOD'] == 'GET': # force roundup to re-parse the request because Zope fiddles @@ -148,10 +149,26 @@ class ZRoundup(Item, PropertyManager, Implicit, Persistent): form = FormWrapper(self.REQUEST.form) return instance.Client(instance, request, env, form) + security.declareProtected('View', 'index_html') def index_html(self): '''Alias index_html to roundup's index ''' + + # Redirect misdirected requests -- bugs 558867 , 565992 + + # PATH_INFO, as defined by the CGI spec, has the *real* request path + orig_path = self.REQUEST.environ[ 'PATH_INFO' ] + if orig_path[-1] != '/' : + url = urlparse.urlparse( self.absolute_url() ) + url = list( url ) # make mutable + url[2] = url[2]+'/' # patch + url = urlparse.urlunparse( url ) # reassemble + RESPONSE = self.REQUEST.RESPONSE + RESPONSE.setStatus( "MovedPermanently" ) # 301 + RESPONSE.setHeader( "Location" , url ) + return RESPONSE + client = self._opendb() # fake the path that roundup should use client.split_path = ['index'] @@ -184,6 +201,9 @@ modulesecurity.apply(globals()) # # $Log: not supported by cvs2svn $ +# Revision 1.6 2002/06/12 00:59:44 dman13 +# Fixed the logic for determing the cookie path. (Closes #562130.) +# # Revision 1.5 2002/05/14 23:36:25 richard # . fixed SCRIPT_NAME in ZRoundup for instances not at top level of Zope # (thanks dman)