mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-30 15:31:09 -05:00
Made sure Http.title doesn't read infinitely.
This commit is contained in:
parent
0b0d10fc82
commit
e15d15f794
@ -53,10 +53,13 @@ import callbacks
|
|||||||
class FreshmeatException(Exception):
|
class FreshmeatException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def getPage(url):
|
def getPage(url, size=None):
|
||||||
"""Gets a page. Returns a string that is the page gotten."""
|
"""Gets a page. Returns a string that is the page gotten."""
|
||||||
fd = urllib2.urlopen(url)
|
fd = urllib2.urlopen(url)
|
||||||
|
if size is None:
|
||||||
text = fd.read()
|
text = fd.read()
|
||||||
|
else:
|
||||||
|
text = fd.read(size)
|
||||||
fd.close()
|
fd.close()
|
||||||
return text
|
return text
|
||||||
|
|
||||||
@ -85,7 +88,7 @@ class Http(callbacks.Privmsg):
|
|||||||
if '://' not in url:
|
if '://' not in url:
|
||||||
url = 'http://%s' % url
|
url = 'http://%s' % url
|
||||||
try:
|
try:
|
||||||
text = getPage(url)
|
text = getPage(url, size=4096)
|
||||||
m = self._titleRe.search(text)
|
m = self._titleRe.search(text)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
irc.reply(msg, utils.htmlToText(m.group(1).strip()))
|
irc.reply(msg, utils.htmlToText(m.group(1).strip()))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user