From e0b9ad980c96a0a8631239c45fac67b051894fef Mon Sep 17 00:00:00 2001 From: Hidden Z Date: Mon, 25 Oct 2010 17:30:42 +0000 Subject: [PATCH] web/jump/views.py: preserve GET variables when redirecting --- web/jump/views.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web/jump/views.py b/web/jump/views.py index 82def58..9c4f946 100644 --- a/web/jump/views.py +++ b/web/jump/views.py @@ -1,3 +1,5 @@ +import re + from django.shortcuts import redirect from django.core.exceptions import ValidationError from django.http import HttpResponse @@ -5,10 +7,10 @@ from django.http import HttpResponse from web.postkey.models import i2phost from web.lib.validation import validate_hostname -def jumper(request, data): +def jumper(request, host): """Actually do jumps.""" try: - hostname = validate_hostname(data) + hostname = validate_hostname(host) except ValidationError, e: return redirect('/jump/error/') try: @@ -16,6 +18,12 @@ def jumper(request, data): except i2phost.DoesNotExist: return redirect('/jump/unknown/') url = 'http://' + hostname + '/?i2paddresshelper=' + key + # get params from requst string, e.g. from 'example.i2p/smth/1?a=b&c=d' get 'smth/1?a=b&c=d' + pattern = host + r'/(.+)' + m = re.search(pattern, request.get_full_path()) + if m: + params = m.group(1) + url += '/' + params return redirect(url, permanent=True) def error(request):