Fixe for bug with titles that spread across lines.

This commit is contained in:
Jeremy Fincher 2003-09-09 21:00:36 +00:00
parent f95a804fe9
commit ecc820a49c
2 changed files with 6 additions and 2 deletions

View File

@ -104,7 +104,7 @@ class Http(callbacks.Privmsg):
self.deepthoughts.add(thought)
irc.reply(msg, thought)
_titleRe = re.compile(r'<title>(.*)</title>', re.I)
_titleRe = re.compile(r'<title>(.*)</title>', re.I | re.S)
def title(self, irc, msg, args):
"""<url>
@ -118,7 +118,7 @@ class Http(callbacks.Privmsg):
text = fd.read()
m = self._titleRe.search(text)
if m is not None:
irc.reply(msg, utils.htmlToText(m.group(1)))
irc.reply(msg, utils.htmlToText(m.group(1).strip()))
else:
irc.reply(msg, 'That URL appears to have no HTML title.')
except ValueError, e:

View File

@ -47,6 +47,10 @@ class HttpTest(PluginTestCase, PluginDocumentation):
'Slashdot: News for nerds, stuff that matters')
self.assertResponse('title http://www.slashdot.org/',
'Slashdot: News for nerds, stuff that matters')
self.assertNotRegexp('http://www.amazon.com/exec/obidos/tg/detail/-/'
'1884822312/qid=1063140754/sr=8-1/ref=sr_8_1/'
'002-9802970-2308826?v=glance&s=books&n=507846',
'no HTML title')
def testGeekquote(self):
self.assertNotError('geekquote')