diff --git a/plugins/Web/plugin.py b/plugins/Web/plugin.py index 378275575..1117d0208 100644 --- a/plugins/Web/plugin.py +++ b/plugins/Web/plugin.py @@ -155,9 +155,10 @@ class Web(callbacks.PluginRegexp): else: return None parser.feed(text) + parser.close() title = parser.title if title: - title = utils.web.htmlToText(parser.title.strip()) + title = utils.web.htmlToText(title.strip()) elif raiseErrors: if len(text) < size: irc.reply(_('That URL appears to have no HTML title.')) diff --git a/plugins/Web/test.py b/plugins/Web/test.py index c78bc7c35..1de573410 100644 --- a/plugins/Web/test.py +++ b/plugins/Web/test.py @@ -67,7 +67,7 @@ class WebTestCase(ChannelPluginTestCase): 'title http://www.youtube.com/watch?v=x4BtiqPN4u8') self.assertResponse( 'title http://www.thefreedictionary.com/don%27t', - "don't - definition of don't by The Free Dictionary") + "Don't - definition of don't by The Free Dictionary") def testTitleSnarfer(self): try: diff --git a/src/utils/web.py b/src/utils/web.py index 8bc280a2d..31adac7e1 100644 --- a/src/utils/web.py +++ b/src/utils/web.py @@ -254,6 +254,7 @@ def htmlToText(s, tagReplace=' '): pass x = HtmlToText(tagReplace) x.feed(s) + x.close() return x.getText() def mungeEmail(s):