mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Catch HTMLParserErrors when we're trying to grab the <title>.
This commit is contained in:
parent
ae5b51fe97
commit
47179f8bc6
@ -86,7 +86,11 @@ class Web(callbacks.PluginRegexp):
|
|||||||
self.log.info('Couldn\'t snarf title of %u: %s.', url, e)
|
self.log.info('Couldn\'t snarf title of %u: %s.', url, e)
|
||||||
return
|
return
|
||||||
parser = Title()
|
parser = Title()
|
||||||
parser.feed(text)
|
try:
|
||||||
|
parser.feed(text)
|
||||||
|
except HTMLParserError:
|
||||||
|
self.log.debug('Unable to parse %u', url)
|
||||||
|
return
|
||||||
if parser.title is not None:
|
if parser.title is not None:
|
||||||
domain = utils.web.getDomain(url)
|
domain = utils.web.getDomain(url)
|
||||||
title = utils.web.htmlToText(parser.title.strip())
|
title = utils.web.htmlToText(parser.title.strip())
|
||||||
@ -158,7 +162,11 @@ class Web(callbacks.PluginRegexp):
|
|||||||
size = conf.supybot.protocols.http.peekSize()
|
size = conf.supybot.protocols.http.peekSize()
|
||||||
text = utils.web.getUrl(url, size=size)
|
text = utils.web.getUrl(url, size=size)
|
||||||
parser = Title()
|
parser = Title()
|
||||||
parser.feed(text)
|
try:
|
||||||
|
parser.feed(text)
|
||||||
|
except HTMLParserError:
|
||||||
|
irc.reply(format('That URL appears to have no HTML title within '
|
||||||
|
'the first %i bytes.', size))
|
||||||
if parser.title is not None:
|
if parser.title is not None:
|
||||||
irc.reply(utils.web.htmlToText(parser.title.strip()))
|
irc.reply(utils.web.htmlToText(parser.title.strip()))
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user