浏览代码

[fix] content escaping - closes #441

TODO check other engines too
Adam Tauber 9 年前
父节点
当前提交
0ad272c5cb
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3
    2
      searx/engines/google.py

+ 3
- 2
searx/engines/google.py 查看文件

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