Fixed the 'title' regexp to be non-greedy, in case there's a </title> tag

within the document itself.  Also put a test for this (which will hopefully be
a permanent link... not sure though)
This commit is contained in:
Daniel DiPaolo 2003-10-24 00:46:21 +00:00
parent aa05fc1a79
commit f0574da59a
2 changed files with 6 additions and 1 deletions

View File

@ -79,7 +79,7 @@ class FreshmeatException(Exception):
class Http(callbacks.Privmsg): class Http(callbacks.Privmsg):
threaded = True threaded = True
_titleRe = re.compile(r'<title>(.*)</title>', re.I | re.S) _titleRe = re.compile(r'<title>(.*?)</title>', re.I | re.S)
def title(self, irc, msg, args): def title(self, irc, msg, args):
"""<url> """<url>

View File

@ -49,6 +49,11 @@ class HttpTest(PluginTestCase, PluginDocumentation):
'1884822312/qid=1063140754/sr=8-1/ref=sr_8_1/' '1884822312/qid=1063140754/sr=8-1/ref=sr_8_1/'
'002-9802970-2308826?v=glance&s=books&n=507846', '002-9802970-2308826?v=glance&s=books&n=507846',
'no HTML title') 'no HTML title')
# Checks the non-greediness of the regexp
self.assertResponse('title '
'http://www.space.com/scienceastronomy/'
'jupiter_dark_spot_031023.html',
'Mystery Spot on Jupiter Baffles Astronomers')
def testGeekquote(self): def testGeekquote(self):
self.assertNotError('geekquote') self.assertNotError('geekquote')