From fa755c3a9c7b87f9bb16475874037db8a30e0e76 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Wed, 10 Aug 2016 22:52:00 +0200 Subject: [PATCH] Google: Decode URLs. Closes GH-1260. --- plugins/Google/plugin.py | 2 +- plugins/Google/test.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index 6c15b7dcb..7ef8e29c0 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -82,7 +82,7 @@ class Google(callbacks.PluginRegexp): results = [] for match in matches: r = dict(zip(('url', 'title', 'cacheUrl', 'content'), match)) - r['url'] = utils.web.htmlToText(r['url'].split('&')[0]) + r['url'] = utils.web.urlunquote(utils.web.htmlToText(r['url'].split('&')[0])) results.append(r) return results diff --git a/plugins/Google/test.py b/plugins/Google/test.py index 68b0e90be..e4e3bd8ca 100644 --- a/plugins/Google/test.py +++ b/plugins/Google/test.py @@ -54,6 +54,12 @@ class GoogleTestCase(ChannelPluginTestCase): # Unicode check self.assertNotError('google ae') + def testUrlDecode(self): + self.assertRegexp( + 'google site:http://www.urbandictionary.com carajo land', + '\x02Urban Dictionary: carajo land\x02: ' + 'https?://www.urbandictionary.com/define.php\?term=carajo%20land') + def testLucky(self): self.assertResponse('lucky Hacker News', 'https://news.ycombinator.com/')