From 57ab09459ffc58e66443a503ebde625c4bd0be1b Mon Sep 17 00:00:00 2001 From: Bill Fenner Date: Tue, 12 Jun 2007 20:49:09 +0000 Subject: [PATCH] Pop command if it's found. Only pop if the key is in the dict. (Note: an alternate implementation would have been pop(arg, '') except the QueryDict doesn't implement that usage) - Legacy-Id: 347 --- ietf/redirects/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ietf/redirects/views.py b/ietf/redirects/views.py index cdad1be64..05da27354 100644 --- a/ietf/redirects/views.py +++ b/ietf/redirects/views.py @@ -12,6 +12,7 @@ def redirect(request, path="", script=""): raise Http404 url = "/" + redir.url + "/" (rest, remove) = (redir.rest, redir.remove) + cmd = None try: cmd = redir.commands.all().get(command=request.REQUEST['command']) if cmd.url: @@ -38,7 +39,11 @@ def redirect(request, path="", script=""): # expecting and if there are any left, add them to the URL. get = request.GET.copy() for arg in re.findall(r'%\(([^)]+)\)', rest): - get.pop(arg) + if get.has_key(arg): + get.pop(arg) + # If we found a command in the database, there's no need to pass it along. + if cmd and get.has_key('command'): + get.pop('command') if get: url += '?' + get.urlencode() return HttpResponsePermanentRedirect(url)