mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-17 06:00:42 +01:00
Web: Fix encoding issue on Python 2. Closes GH-1359.
This commit is contained in:
parent
624553c069
commit
0f82f89eec
@ -156,14 +156,20 @@ class Web(callbacks.PluginRegexp):
|
|||||||
'replace')
|
'replace')
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
pass
|
pass
|
||||||
parser = Title()
|
|
||||||
if minisix.PY3 and isinstance(text, bytes):
|
if minisix.PY3 and isinstance(text, bytes):
|
||||||
if raiseErrors:
|
if raiseErrors:
|
||||||
irc.error(_('Could not guess the page\'s encoding. (Try '
|
irc.error(_('Could not guess the page\'s encoding. (Try '
|
||||||
'installing python-charade.)'), Raise=True)
|
'installing python-charade.)'), Raise=True)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
parser.feed(text)
|
try:
|
||||||
|
parser = Title()
|
||||||
|
parser.feed(text)
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
# Workaround for Python 2
|
||||||
|
# https://github.com/ProgVal/Limnoria/issues/1359
|
||||||
|
parser = Title()
|
||||||
|
parser.feed(text.encode('utf8'))
|
||||||
parser.close()
|
parser.close()
|
||||||
title = utils.str.normalizeWhitespace(''.join(parser.data).strip())
|
title = utils.str.normalizeWhitespace(''.join(parser.data).strip())
|
||||||
if title:
|
if title:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user