Selaa lähdekoodia

[fix] proper html escaping

asciimoo 11 vuotta sitten
vanhempi
commit
e47258ce38
1 muutettua tiedostoa jossa 2 lisäystä ja 1 poistoa
  1. 2
    1
      searx/engines/stackoverflow.py

+ 2
- 1
searx/engines/stackoverflow.py Näytä tiedosto

@@ -1,6 +1,7 @@
1 1
 from urllib import quote
2 2
 from lxml import html
3 3
 from urlparse import urljoin
4
+from cgi import escape
4 5
 
5 6
 base_url = 'http://stackoverflow.com/'
6 7
 search_url = base_url+'search?q='
@@ -20,6 +21,6 @@ def response(resp):
20 21
         link = result.xpath('.//div[@class="result-link"]//a')[0]
21 22
         url = urljoin(base_url, link.attrib.get('href'))
22 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 25
         results.append({'url': url, 'title': title, 'content': content})
25 26
     return results