Web: Add explicit error when page encoding cannot be guessed.

This commit is contained in:
Valentin Lorentz 2014-10-13 01:13:15 +00:00
parent d2046a81a2
commit 8ab29fb291
1 changed files with 4 additions and 1 deletions

View File

@ -270,9 +270,12 @@ class Web(callbacks.PluginRegexp):
try: try:
text = text.decode(utils.web.getEncoding(text) or 'utf8', text = text.decode(utils.web.getEncoding(text) or 'utf8',
'replace') 'replace')
except: except UnicodeDecodeError:
pass pass
parser = Title() 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: try:
parser.feed(text) parser.feed(text)
except HTMLParser.HTMLParseError: except HTMLParser.HTMLParseError: