[mirrorbrain-commits] r7946 - in /trunk/mirrordoctor/mb: mirrorlists.py util.py

From: <poeml_at_mirrorbrain.org>
Date: Wed, 27 Jan 2010 00:25:22 -0000
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
_at_@ -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
_at_@ -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 '_at_' in netloc:
+        netloc = netloc.split('_at_')[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.org
Received on Wed Jan 27 2010 - 00:25:22 GMT

This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT