[Yum-devel] [PATCH] URL sanity checking. BZ 822632

Zdeněk Pavlas zpavlas at redhat.com
Fri May 18 08:42:26 UTC 2012


Ignore bogus hostnames, and make parsing of timedhosts file
a bit more robust.
---
 urlgrabber/grabber.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
index 094be77..1d7cfbe 100644
--- a/urlgrabber/grabber.py
+++ b/urlgrabber/grabber.py
@@ -2268,7 +2268,7 @@ class _TH:
         if filename and _TH.dirty is None:
             try:
                 for line in open(filename):
-                    host, speed, fail, ts = line.split()
+                    host, speed, fail, ts = line.split(' ', 3)
                     _TH.hosts[host] = int(speed), int(fail), int(ts)
             except IOError: pass
             _TH.dirty = False
@@ -2291,6 +2291,9 @@ class _TH:
     def update(url, dl_size, dl_time, ug_err):
         _TH.load()
         host = urlparse.urlsplit(url).netloc
+        if not host or ' ' in host:
+            DEBUG.warn('malformed url: %s', repr(url))
+            return
         speed, fail, ts = _TH.hosts.get(host) or (0, 0, 0)
         now = time.time()
 
-- 
1.7.4.4



More information about the Yum-devel mailing list