From: Magnus Hagander Date: Tue, 13 Jun 2017 12:55:30 +0000 (+0200) Subject: When redirecting, ignore querystring part (after ?) of URL X-Git-Url: http://git.postgresql.org/gitweb/static/%7B%7Bpguslink%28?a=commitdiff_plain;h=547f0241b747f3ea52ebddd4c5ca094e9f526b4a;p=hamn.git When redirecting, ignore querystring part (after ?) of URL This can sometimes be added by some broken trackers, but we can safely ignore it completely. Reported by Stefan Kaltenbrunner --- diff --git a/redirector/redirector.py b/redirector/redirector.py index 7f918f8..27f15f0 100755 --- a/redirector/redirector.py +++ b/redirector/redirector.py @@ -26,8 +26,15 @@ def iddecode(idstr): def application(environ, start_response): try: + # If we have a querystring, get rid of it. This can (presumably) + # happen with some click-tracking systems. + if '?' in environ['REQUEST_URI']: + uri = environ['REQUEST_URI'].split('?')[0] + else: + uri = environ['REQUEST_URI'] + # Start by getting the id from the request - id = iddecode(environ['REQUEST_URI'].split('/')[-1]) + id = iddecode(uri.split('/')[-1]) # Let's figure out where this URL should be