Repository :
http://git.fedorahosted.org/cgit/
On branch : master
---------------------------------------------------------------
commit ec0c2db90452367eae2567b1cc1401ad9f2b1a78
Author: Matt Domsch <matt(a)domsch.com>
Date: Wed Dec 18 22:57:33 2013 -0600
mirrorlist_client: don't return redirects to non-HTTP servers
https://fedorahosted.org/fedora-infrastructure/ticket/3610
---------------------------------------------------------------
mirrorlist-server/mirrorlist_client.wsgi | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/mirrorlist-server/mirrorlist_client.wsgi
b/mirrorlist-server/mirrorlist_client.wsgi
index 5f49cda..a4853e9 100755
--- a/mirrorlist-server/mirrorlist_client.wsgi
+++ b/mirrorlist-server/mirrorlist_client.wsgi
@@ -134,6 +134,13 @@ def manage_compression(request, response, buf):
response.headers['Content-Encoding'] = 'gzip'
return buf
+def keep_only_http_results(input):
+ output = []
+ for hostid, url in input:
+ if url.startswith(u'http'):
+ output.append((hostid, url))
+ return output
+
def application(environ, start_response):
request = WSGIRequest(environ)
response = WSGIResponse()
@@ -155,12 +162,15 @@ def application(environ, start_response):
if 'redirect' in request.GET:
if len(results) == 0:
response.status_code=404
- return response(environ, start_response)
else:
- (hostid, url) = results[0]
- response.status_code=302
- response.headers['Location'] = str(url)
- return response(environ, start_response)
+ results = keep_only_http_results(results)
+ if len(results):
+ (hostid, url) = results[0]
+ response.status_code=302
+ response.headers['Location'] = str(url)
+ else:
+ response.status_code=404
+ return response(environ, start_response)
text = ""
text += message + '\n'