Browse Source

[fix] skip invalid encoded attributes

Adam Tauber 5 years ago
parent
commit
2dc2e1e8f9
1 changed files with 17 additions and 9 deletions
  1. 17 9
      searx/engines/flickr_noapi.py

+ 17 - 9
searx/engines/flickr_noapi.py

@@ -109,14 +109,22 @@ def response(resp):
         else:
         else:
             url = build_flickr_url(photo['ownerNsid'], photo['id'])
             url = build_flickr_url(photo['ownerNsid'], photo['id'])
 
 
-        results.append({'url': url,
-                        'title': title,
-                        'img_src': img_src,
-                        'thumbnail_src': thumbnail_src,
-                        'content': content,
-                        'author': author,
-                        'source': source,
-                        'img_format': img_format,
-                        'template': 'images.html'})
+        result = {
+            'url': url,
+            'img_src': img_src,
+            'thumbnail_src': thumbnail_src,
+            'source': source,
+            'img_format': img_format,
+            'template': 'images.html'
+        }
+        try:
+            result['author'] = author.encode('utf-8')
+            result['title'] = title.encode('utf-8')
+            result['content'] = content.encode('utf-8')
+        except:
+            result['author'] = ''
+            result['title'] = ''
+            result['content'] = ''
+        results.append(result)
 
 
     return results
     return results