소스 검색

[fix] proper html escaping

asciimoo 11 년 전
부모
커밋
e47258ce38
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2
    1
      searx/engines/stackoverflow.py

+ 2
- 1
searx/engines/stackoverflow.py 파일 보기

1
 from urllib import quote
1
 from urllib import quote
2
 from lxml import html
2
 from lxml import html
3
 from urlparse import urljoin
3
 from urlparse import urljoin
4
+from cgi import escape
4
 
5
 
5
 base_url = 'http://stackoverflow.com/'
6
 base_url = 'http://stackoverflow.com/'
6
 search_url = base_url+'search?q='
7
 search_url = base_url+'search?q='
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