Package: moin Severity: normal Tags: patch Moin 1.3.5 and 1.5.0beta3 fail to correctly handle the use of PythonOption to overcome problems with being run as a handler (incorrect script_name and path_info).
RequestModPy uses a get method that's not always available with a mod_python table object (worked around elsewhere in request.py, but not here), and ignores the fact that script_name is not set correctly (or usefully, at least) by Apache. The script_name bug bites when the wiki is not at the top level (e.g. "www.foo.com/wikis/moinwiki" instead of "www.foo.com/moinwiki", which would work). Patch provided *shouldn't* break anything on any other OS/webserver/config. Patch follows: --- MoinMoin/request.py 2005-10-30 11:55:39.000000000 +1300 +++ MoinMoin/request.py-new 2005-11-17 14:10:45.000000000 +1300 @@ -1786,8 +1786,9 @@ except Exception, err: self.fail(err) - def rewriteURI(self, env): - """ Use PythonOption directive to rewrite URI + def fixURI(self, env): + """ Fix problems with script_name and path_info using + PythonOption directive to rewrite URI. This is needed when using Apache 1 or other server which does not support adding custom headers per request. With mod python we @@ -1795,16 +1796,31 @@ <Location /url/to/mywiki/> PythonOption X-Moin-Location /url/to/mywiki/ - </location> + </location> + + Note that *neither* script_name *nor* path_info can be trusted + when Moin is invoked as a mod_python handler with apache1, so we + must build both using request_uri and the provided PythonOption. """ # Be compatible with release 1.3.5 "Location" option # TODO: Remove in later release, we should have one option only. old_location = 'Location' - options = self.mpyreq.get_options() + options_table = self.mpyreq.get_options() + if not hasattr(options_table,'get'): + options=dict(options_table) + else: + options=options_table location = options.get(self.moin_location) or options.get(old_location) if location: env[self.moin_location] = location - RequestBase.rewriteURI(self, env) + # Try to recreate script_name and path_info from request_uri. + import urlparse + scriptAndPath = urlparse.urlparse(self.request_uri)[2] + self.script_name = location.rstrip('/') + path = scriptAndPath.replace(self.script_name, '', 1) + self.path_info = wikiutil.url_unquote(path, want_unicode=False) + + RequestBase.fixURI(self, env) def _setup_args_from_cgi_form(self, form=None): """ Override to use mod_python.util.FieldStorage -- System Information: Debian Release: 3.1 APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Kernel: Linux 2.6.11nwp1 Locale: LANG=en_NZ.UTF-8, LC_CTYPE=en_NZ.UTF-8 (charmap=UTF-8) -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]