mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-03-01 12:00:41 +01:00
Fixe for bug with titles that spread across lines.
This commit is contained in:
parent
f95a804fe9
commit
ecc820a49c
@ -104,7 +104,7 @@ class Http(callbacks.Privmsg):
|
|||||||
self.deepthoughts.add(thought)
|
self.deepthoughts.add(thought)
|
||||||
irc.reply(msg, 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):
|
def title(self, irc, msg, args):
|
||||||
"""<url>
|
"""<url>
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ class Http(callbacks.Privmsg):
|
|||||||
text = fd.read()
|
text = fd.read()
|
||||||
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)))
|
irc.reply(msg, utils.htmlToText(m.group(1).strip()))
|
||||||
else:
|
else:
|
||||||
irc.reply(msg, 'That URL appears to have no HTML title.')
|
irc.reply(msg, 'That URL appears to have no HTML title.')
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
|
@ -47,6 +47,10 @@ class HttpTest(PluginTestCase, PluginDocumentation):
|
|||||||
'Slashdot: News for nerds, stuff that matters')
|
'Slashdot: News for nerds, stuff that matters')
|
||||||
self.assertResponse('title http://www.slashdot.org/',
|
self.assertResponse('title http://www.slashdot.org/',
|
||||||
'Slashdot: News for nerds, stuff that matters')
|
'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):
|
def testGeekquote(self):
|
||||||
self.assertNotError('geekquote')
|
self.assertNotError('geekquote')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user