[Yum-devel] [PATCH] URL sanity checking. BZ 822632
James Antill
james at fedoraproject.org
Fri May 18 14:28:03 UTC 2012
On Fri, 2012-05-18 at 10:42 +0200, Zdeněk Pavlas wrote:
> Ignore bogus hostnames, and make parsing of timedhosts file
> a bit more robust.
ACK.
> ---
> 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)
Is it worth adding some try/except stuff ... esp. for any people who
have a corrupt hosts file already?
> _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
This triggers for "file:" urls atm., right? Pretty sure we don't want
to do that.
More information about the Yum-devel
mailing list