From 8ab29fb291a7919215a156e16d2296d234312096 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Mon, 13 Oct 2014 01:13:15 +0000 Subject: [PATCH] Web: Add explicit error when page encoding cannot be guessed. --- plugins/Web/plugin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/Web/plugin.py b/plugins/Web/plugin.py index a794de673..42150215a 100644 --- a/plugins/Web/plugin.py +++ b/plugins/Web/plugin.py @@ -270,9 +270,12 @@ class Web(callbacks.PluginRegexp): try: text = text.decode(utils.web.getEncoding(text) or 'utf8', 'replace') - except: + except UnicodeDecodeError: pass parser = Title() + if sys.version_info[0] >= 3 and isinstance(text, bytes): + irc.error(_('Could not guess the page\'s encoding. (Try ' + 'installing python-charade'), Raise=True) try: parser.feed(text) except HTMLParser.HTMLParseError: