summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2019-08-02 13:37:13 +0200
committerGitHub <noreply@github.com>2019-08-02 13:37:13 +0200
commit2179079a9173b33b81e1084fc1e8e181c19ef8e9 (patch)
tree081289e4baa95e731c5a849b22d663b0a7788f56 /tests
parent4dc792e1e2d3771b6d6620f5d564ea091597c4dc (diff)
downloadsearxng-2179079a9173b33b81e1084fc1e8e181c19ef8e9.tar.gz
searxng-2179079a9173b33b81e1084fc1e8e181c19ef8e9.zip
[fix] fix flickr_noapi decoding (#1655)
Characters that were not ASCII were incorrectly decoded. Add an helper function: searx.utils.ecma_unescape (Python implementation of unescape Javascript function).
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_utils.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py
index fbaed2bd1..b09b9d414 100644
--- a/tests/unit/test_utils.py
+++ b/tests/unit/test_utils.py
@@ -90,6 +90,13 @@ class TestUtils(SearxTestCase):
self.assertEqual(utils.match_language('iw-IL', ['he-IL']), 'he-IL')
self.assertEqual(utils.match_language('he-IL', ['iw-IL'], aliases), 'iw-IL')
+ def test_ecma_unscape(self):
+ self.assertEqual(utils.ecma_unescape('text%20with%20space'), 'text with space')
+ self.assertEqual(utils.ecma_unescape('text using %xx: %F3'),
+ u'text using %xx: ó')
+ self.assertEqual(utils.ecma_unescape('text using %u: %u5409, %u4E16%u754c'),
+ u'text using %u: 吉, 世界')
+
class TestHTMLTextExtractor(SearxTestCase):