From 22febc4a207b305077cc6bf5065928042d7a00e5 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 17 Nov 2012 15:10:36 +0000 Subject: [PATCH] Web: Fix encoding issues in title snarfing and @title. --- plugins/Web/plugin.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/Web/plugin.py b/plugins/Web/plugin.py index e6be52593..42f7e3e9b 100644 --- a/plugins/Web/plugin.py +++ b/plugins/Web/plugin.py @@ -92,8 +92,9 @@ class Web(callbacks.PluginRegexp): return try: size = conf.supybot.protocols.http.peekSize() - text = utils.web.getUrl(url, size=size) \ - .decode('utf8') + text = utils.web.getUrl(url, size=size) + if sys.version_info[0] >= 3: + text = text.encode('utf8', 'replace') except utils.web.Error, e: self.log.info('Couldn\'t snarf title of %u: %s.', url, e) return @@ -182,8 +183,9 @@ class Web(callbacks.PluginRegexp): DCC, ...). """ size = conf.supybot.protocols.http.peekSize() - text = utils.web.getUrl(url, size=size) \ - .decode('utf8') + text = utils.web.getUrl(url, size=size) + if sys.version_info[0] >= 3: + text = text.encode('utf8', 'replace') parser = Title() try: parser.feed(text)