From ecc820a49c9e365e525761d3ab3c75865c6f3398 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 9 Sep 2003 21:00:36 +0000 Subject: [PATCH] Fixe for bug with titles that spread across lines. --- plugins/Http.py | 4 ++-- test/test_Http.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/Http.py b/plugins/Http.py index a62d39263..dac643bd2 100644 --- a/plugins/Http.py +++ b/plugins/Http.py @@ -104,7 +104,7 @@ class Http(callbacks.Privmsg): self.deepthoughts.add(thought) irc.reply(msg, thought) - _titleRe = re.compile(r'(.*)', re.I) + _titleRe = re.compile(r'(.*)', re.I | re.S) def title(self, irc, msg, args): """ @@ -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: diff --git a/test/test_Http.py b/test/test_Http.py index 4b84885b2..868f209cc 100644 --- a/test/test_Http.py +++ b/test/test_Http.py @@ -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')