Browse Source

[fix] content escaping - closes #441

TODO check other engines too
Adam Tauber 9 years ago
parent
commit
0ad272c5cb
1 changed files with 3 additions and 2 deletions
  1. 3
    2
      searx/engines/google.py

+ 3
- 2
searx/engines/google.py View File

@@ -9,6 +9,7 @@
9 9
 # @parse       url, title, content, suggestion
10 10
 
11 11
 import re
12
+from cgi import escape
12 13
 from urllib import urlencode
13 14
 from urlparse import urlparse, parse_qsl
14 15
 from lxml import html
@@ -167,7 +168,7 @@ def parse_url(url_string, google_hostname):
167 168
 def extract_text_from_dom(result, xpath):
168 169
     r = result.xpath(xpath)
169 170
     if len(r) > 0:
170
-        return extract_text(r[0])
171
+        return escape(extract_text(r[0]))
171 172
     return None
172 173
 
173 174
 
@@ -273,7 +274,7 @@ def response(resp):
273 274
     # parse suggestion
274 275
     for suggestion in dom.xpath(suggestion_xpath):
275 276
         # append suggestion
276
-        results.append({'suggestion': extract_text(suggestion)})
277
+        results.append({'suggestion': escape(extract_text(suggestion))})
277 278
 
278 279
     # return results
279 280
     return results