From e15d15f79462b49c6099d483fc4d052d252d42e6 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sat, 29 Nov 2003 02:34:07 +0000 Subject: [PATCH] Made sure Http.title doesn't read infinitely. --- plugins/Http.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/Http.py b/plugins/Http.py index 540c2815e..3625aeed9 100644 --- a/plugins/Http.py +++ b/plugins/Http.py @@ -53,10 +53,13 @@ import callbacks class FreshmeatException(Exception): pass -def getPage(url): +def getPage(url, size=None): """Gets a page. Returns a string that is the page gotten.""" fd = urllib2.urlopen(url) - text = fd.read() + if size is None: + text = fd.read() + else: + text = fd.read(size) fd.close() return text @@ -85,7 +88,7 @@ class Http(callbacks.Privmsg): if '://' not in url: url = 'http://%s' % url try: - text = getPage(url) + text = getPage(url, size=4096) m = self._titleRe.search(text) if m is not None: irc.reply(msg, utils.htmlToText(m.group(1).strip()))