Edgewall Software
Modify

Opened 10 years ago

Closed 9 years ago

Last modified 5 years ago

#9513 closed defect (fixed)

spam filter captcha redirect incorrect when not installed at root

Reported by: michaelc@… Owned by: Dirk Stöcker
Priority: normal Milestone:
Component: plugin/spamfilter Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:

Description

Upon successful captcha match, the captcha_redirect value is matched directly against request handlers to match the appropriate redirect. For projects where Trac is not installed at the root level (i.e. https://mydomain.com/trac/myproject), the handlers do not match because the PATH_INFO includes the base url (i.e. /trac/myproject/newticket).

Stripping SCRIPT_NAME if it is present and not '/' should prevent this from happening. We are using the following patch:

Index: tracspamfilter/captcha/api.py
===================================================================
--- tracspamfilter/captcha/api.py	(revision 9965)
+++ tracspamfilter/captcha/api.py	(working copy)
@@ -93,6 +93,8 @@
         if(req.path_info == '/captcha' and req.method == 'POST' and
         req.args['captcha_response'] == req.session['captcha_expected']):
             req.environ['PATH_INFO'] = req.session.get('captcha_redirect', req.href())
+            if ('SCRIPT_NAME' in req.environ and len(req.environ['SCRIPT_NAME']) > 1):
+                req.environ['PATH_INFO'] = req.environ['PATH_INFO'].replace(req.environ['SCRIPT_NAME'], '')
             del req.session['captcha_redirect']
             del req.session['captcha_reject_reason']
             req.session['captcha_verified'] = int(time.time())

Attachments (0)

Change History (1)

comment:1 by Dirk Stöcker, 9 years ago

Resolution: fixed
Status: newclosed

In r9993.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Dirk Stöcker.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from Dirk Stöcker to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.