Google: fix encoding bug in lucky --snippet; need to pass encoded string to utils.web.htmlToText

This commit is contained in:
Daniel Folkinshteyn 2010-07-26 09:22:07 -04:00 committed by Valentin Lorentz
parent 614e6c3f43
commit a6b9d5fe5f

View File

@ -172,14 +172,14 @@ class Google(callbacks.PluginRegexp):
opts = dict(opts) opts = dict(opts)
data = self.search(text, msg.args[0], {'smallsearch': True}) data = self.search(text, msg.args[0], {'smallsearch': True})
if data['responseData']['results']: if data['responseData']['results']:
url = data['responseData']['results'][0]['unescapedUrl'] url = data['responseData']['results'][0]['unescapedUrl'].encode('utf-8')
if opts.has_key('snippet'): if opts.has_key('snippet'):
snippet = data['responseData']['results'][0]['content'] snippet = data['responseData']['results'][0]['content'].encode('utf-8')
snippet = " | " + utils.web.htmlToText(snippet, tagReplace='') snippet = " | " + utils.web.htmlToText(snippet, tagReplace='')
else: else:
snippet = "" snippet = ""
result = url + snippet result = url + snippet
irc.reply(result.encode('utf-8')) irc.reply(result)
else: else:
irc.reply(_('Google found nothing.')) irc.reply(_('Google found nothing.'))
lucky = wrap(lucky, [getopts({'snippet':'',}), 'text']) lucky = wrap(lucky, [getopts({'snippet':'',}), 'text'])