mirror of
https://github.com/searxng/searxng.git
synced 2024-11-19 19:00:10 +01:00
[fix] swisscow and yandex escaping - fixes #499
This commit is contained in:
parent
c61ea820d2
commit
e061c6e059
@ -10,6 +10,7 @@
|
|||||||
@parse url, title, content
|
@parse url, title, content
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from cgi import escape
|
||||||
from json import loads
|
from json import loads
|
||||||
from urllib import urlencode, unquote
|
from urllib import urlencode, unquote
|
||||||
import re
|
import re
|
||||||
@ -77,7 +78,7 @@ def response(resp):
|
|||||||
|
|
||||||
# append result
|
# append result
|
||||||
results.append({'url': result['SourceUrl'],
|
results.append({'url': result['SourceUrl'],
|
||||||
'title': result['Title'],
|
'title': escape(result['Title']),
|
||||||
'content': '',
|
'content': '',
|
||||||
'img_src': img_url,
|
'img_src': img_url,
|
||||||
'template': 'images.html'})
|
'template': 'images.html'})
|
||||||
@ -89,8 +90,8 @@ def response(resp):
|
|||||||
|
|
||||||
# append result
|
# append result
|
||||||
results.append({'url': result_url,
|
results.append({'url': result_url,
|
||||||
'title': result_title,
|
'title': escape(result_title),
|
||||||
'content': result_content})
|
'content': escape(result_content)})
|
||||||
|
|
||||||
# parse images
|
# parse images
|
||||||
for result in json.get('Images', []):
|
for result in json.get('Images', []):
|
||||||
@ -99,7 +100,7 @@ def response(resp):
|
|||||||
|
|
||||||
# append result
|
# append result
|
||||||
results.append({'url': result['SourceUrl'],
|
results.append({'url': result['SourceUrl'],
|
||||||
'title': result['Title'],
|
'title': escape(result['Title']),
|
||||||
'content': '',
|
'content': '',
|
||||||
'img_src': img_url,
|
'img_src': img_url,
|
||||||
'template': 'images.html'})
|
'template': 'images.html'})
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
@parse url, title, content
|
@parse url, title, content
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from cgi import escape
|
||||||
from urllib import urlencode
|
from urllib import urlencode
|
||||||
from lxml import html
|
from lxml import html
|
||||||
from searx.search import logger
|
from searx.search import logger
|
||||||
@ -51,8 +52,8 @@ def response(resp):
|
|||||||
for result in dom.xpath(results_xpath):
|
for result in dom.xpath(results_xpath):
|
||||||
try:
|
try:
|
||||||
res = {'url': result.xpath(url_xpath)[0],
|
res = {'url': result.xpath(url_xpath)[0],
|
||||||
'title': ''.join(result.xpath(title_xpath)),
|
'title': escape(''.join(result.xpath(title_xpath))),
|
||||||
'content': ''.join(result.xpath(content_xpath))}
|
'content': escape(''.join(result.xpath(content_xpath)))}
|
||||||
except:
|
except:
|
||||||
logger.exception('yandex parse crash')
|
logger.exception('yandex parse crash')
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user