From 7a3be8a8e5a0db8269ffbf2fa3025acc1178c4aa Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 31 Aug 2004 16:15:17 +0000 Subject: [PATCH] Catch httplib.InvalidURL. --- src/webutils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/webutils.py b/src/webutils.py index 47e64b141..e2483a2f5 100644 --- a/src/webutils.py +++ b/src/webutils.py @@ -36,6 +36,7 @@ import supybot.fix as fix import re import socket import urllib2 +import httplib import urlparse import supybot.conf as conf @@ -44,6 +45,7 @@ Request = urllib2.Request class WebError(Exception): pass +# XXX We should tighten this up a bit. urlRe = re.compile(r"(\w+://[^\])>\s]+)", re.I) REFUSED = 'Connection refused.' @@ -94,6 +96,8 @@ def getUrlFd(url, headers=None): raise WebError, TIMED_OUT except (socket.error, socket.sslerror), e: raise WebError, strError(e) + except httplib.InvalidURL, e: + raise WebError, 'Invalid URL: %s' % e except urllib2.HTTPError, e: raise WebError, strError(e) except urllib2.URLError, e: