on master help sign in
[fix] proper html escaping
e47258casciimoo
searx/engines/stackoverflow.py+2−1
@@ -1,6 +1,7 @@
1from urllib import quote
1from urllib import quote
2from lxml import html
2from lxml import html
3from urlparse import urljoin
3from urlparse import urljoin
4+from cgi import escape
4
5
5base_url = 'http://stackoverflow.com/'
6base_url = 'http://stackoverflow.com/'
6search_url = base_url+'search?q='
7search_url = base_url+'search?q='
@@ -20,6 +21,6 @@ def response(resp):
20 link = result.xpath('.//div[@class="result-link"]//a')[0]
21 link = result.xpath('.//div[@class="result-link"]//a')[0]
21 url = urljoin(base_url, link.attrib.get('href'))
22 url = urljoin(base_url, link.attrib.get('href'))
22 title = ' '.join(link.xpath('.//text()'))
23 title = ' '.join(link.xpath('.//text()'))
23− content = ' '.join(result.xpath('.//div[@class="excerpt"]//text()'))
24+ content = escape(' '.join(result.xpath('.//div[@class="excerpt"]//text()')))
24 results.append({'url': url, 'title': title, 'content': content})
25 results.append({'url': url, 'title': title, 'content': content})
25 return results
26 return results