Author: poeml Date: Wed Jan 27 01:25:21 2010 New Revision: 7946 URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=7946&view=rev Log: mb mirrorlist: - remove authentication data from URLs when generating mirror lists. The assumption is that if such data ends up there it'll most likely be unintentional. Modified: trunk/mirrordoctor/mb/mirrorlists.py trunk/mirrordoctor/mb/util.py Modified: trunk/mirrordoctor/mb/mirrorlists.py URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mirrordoctor/mb/mirrorlists.py?rev=7946&r1=7945&r2=7946&view=diff ============================================================================== --- trunk/mirrordoctor/mb/mirrorlists.py (original) +++ trunk/mirrordoctor/mb/mirrorlists.py Wed Jan 27 01:25:21 2010 @@ -254,9 +254,9 @@ 'identifier': mirror.identifier, 'operatorName': cgi.escape(mirror.operatorName), 'operatorUrl': mirror.operatorUrl, - 'http_link': href(mirror.baseurl, 'HTTP'), - 'ftp_link': href(mirror.baseurlFtp, 'FTP'), - 'rsync_link': href(mirror.baseurlRsync, 'rsync'), + 'http_link': href(mb.util.strip_auth(mirror.baseurl), 'HTTP'), + 'ftp_link': href(mb.util.strip_auth(mirror.baseurlFtp), 'FTP'), + 'rsync_link': href(mb.util.strip_auth(mirror.baseurlRsync), 'rsync'), 'prio': stars(mirror.score), } Modified: trunk/mirrordoctor/mb/util.py URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mirrordoctor/mb/util.py?rev=7946&r1=7945&r2=7946&view=diff ============================================================================== --- trunk/mirrordoctor/mb/util.py (original) +++ trunk/mirrordoctor/mb/util.py Wed Jan 27 01:25:21 2010 @@ -168,3 +168,18 @@ else: return '%s seconds' % int(t_delta) + +def strip_auth(s): + """remove user/password from URLs. The URL is split into + <scheme>://<netloc>/<path>;<params>?<query>#<fragment> + with the urlparse module and and returned reassembled. + """ + + import urlparse + + u = urlparse.urlsplit(s) + netloc = u[1] + if '@' in netloc: + netloc = netloc.split('@')[1] + return urlparse.urlunsplit((u[0], netloc, u[2], u[3], u[4])) + _______________________________________________ mirrorbrain-commits mailing list Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/ Note: To remove yourself from this list, send a mail with the content unsubscribe to the address mirrorbrain-commits-request_at_mirrorbrain.orgReceived on Wed Jan 27 2010 - 00:25:22 GMT
This archive was generated by hypermail 2.2.0 : Wed Jan 27 2010 - 00:32:10 GMT