on master help sign in
[mod] do not escape html content in engines
16bdc0bAdam Tauber
searx/engines/archlinux.py+1−2
@@ -12,7 +12,6 @@
12"""
12"""
13
13
14from urlparse import urljoin
14from urlparse import urljoin
15−from cgi import escape
16from urllib import urlencode
15from urllib import urlencode
17from lxml import html
16from lxml import html
18from searx.engines.xpath import extract_text
17from searx.engines.xpath import extract_text
@@ -135,7 +134,7 @@ def response(resp):
135 for result in dom.xpath(xpath_results):
134 for result in dom.xpath(xpath_results):
136 link = result.xpath(xpath_link)[0]
135 link = result.xpath(xpath_link)[0]
137 href = urljoin(base_url, link.attrib.get('href'))
136 href = urljoin(base_url, link.attrib.get('href'))
138− title = escape(extract_text(link))
137+ title = extract_text(link)
139
138
140 results.append({'url': href,
139 results.append({'url': href,
141 'title': title})
140 'title': title})
searx/engines/base.py+1−2
@@ -16,7 +16,6 @@
16from lxml import etree
16from lxml import etree
17from urllib import urlencode
17from urllib import urlencode
18from searx.utils import searx_useragent
18from searx.utils import searx_useragent
19−from cgi import escape
20from datetime import datetime
19from datetime import datetime
21import re
20import re
22
21
@@ -94,7 +93,7 @@ def response(resp):
94 url = item.text
93 url = item.text
95
94
96 elif item.attrib["name"] == "dcdescription":
95 elif item.attrib["name"] == "dcdescription":
97− content = escape(item.text[:300])
96+ content = item.text[:300]
98 if len(item.text) > 300:
97 if len(item.text) > 300:
99 content += "..."
98 content += "..."
100
99
searx/engines/bing.py+2−3
@@ -14,7 +14,6 @@
14"""
14"""
15
15
16from urllib import urlencode
16from urllib import urlencode
17−from cgi import escape
18from lxml import html
17from lxml import html
19from searx.engines.xpath import extract_text
18from searx.engines.xpath import extract_text
20
19
@@ -61,7 +60,7 @@ def response(resp):
61 link = result.xpath('.//h3/a')[0]
60 link = result.xpath('.//h3/a')[0]
62 url = link.attrib.get('href')
61 url = link.attrib.get('href')
63 title = extract_text(link)
62 title = extract_text(link)
64− content = escape(extract_text(result.xpath('.//p')))
63+ content = extract_text(result.xpath('.//p'))
65
64
66 # append result
65 # append result
67 results.append({'url': url,
66 results.append({'url': url,
@@ -73,7 +72,7 @@ def response(resp):
73 link = result.xpath('.//h2/a')[0]
72 link = result.xpath('.//h2/a')[0]
74 url = link.attrib.get('href')
73 url = link.attrib.get('href')
75 title = extract_text(link)
74 title = extract_text(link)
76− content = escape(extract_text(result.xpath('.//p')))
75+ content = extract_text(result.xpath('.//p'))
77
76
78 # append result
77 # append result
79 results.append({'url': url,
78 results.append({'url': url,
searx/engines/btdigg.py+2−3
@@ -11,7 +11,6 @@
11"""
11"""
12
12
13from urlparse import urljoin
13from urlparse import urljoin
14−from cgi import escape
15from urllib import quote
14from urllib import quote
16from lxml import html
15from lxml import html
17from operator import itemgetter
16from operator import itemgetter
@@ -51,8 +50,8 @@ def response(resp):
51 for result in search_res:
50 for result in search_res:
52 link = result.xpath('.//td[@class="torrent_name"]//a')[0]
51 link = result.xpath('.//td[@class="torrent_name"]//a')[0]
53 href = urljoin(url, link.attrib.get('href'))
52 href = urljoin(url, link.attrib.get('href'))
54− title = escape(extract_text(link))
53+ title = extract_text(link)
55− content = escape(extract_text(result.xpath('.//pre[@class="snippet"]')[0]))
54+ content = extract_text(result.xpath('.//pre[@class="snippet"]')[0])
56 content = "<br />".join(content.split("\n"))
55 content = "<br />".join(content.split("\n"))
57
56
58 filesize = result.xpath('.//span[@class="attr_val"]/text()')[0].split()[0]
57 filesize = result.xpath('.//span[@class="attr_val"]/text()')[0].split()[0]
searx/engines/dailymotion.py+1−2
@@ -14,7 +14,6 @@
14
14
15from urllib import urlencode
15from urllib import urlencode
16from json import loads
16from json import loads
17−from cgi import escape
18from datetime import datetime
17from datetime import datetime
19
18
20# engine dependent config
19# engine dependent config
@@ -57,7 +56,7 @@ def response(resp):
57 for res in search_res['list']:
56 for res in search_res['list']:
58 title = res['title']
57 title = res['title']
59 url = res['url']
58 url = res['url']
60− content = escape(res['description'])
59+ content = res['description']
61 thumbnail = res['thumbnail_360_url']
60 thumbnail = res['thumbnail_360_url']
62 publishedDate = datetime.fromtimestamp(res['created_time'], None)
61 publishedDate = datetime.fromtimestamp(res['created_time'], None)
63 embedded = embedded_url.format(videoid=res['id'])
62 embedded = embedded_url.format(videoid=res['id'])
searx/engines/deezer.py+5−4
@@ -51,10 +51,11 @@ def response(resp):
51 if url.startswith('http://'):
51 if url.startswith('http://'):
52 url = 'https' + url[4:]
52 url = 'https' + url[4:]
53
53
54+ content = '{} - {} - {}'.format(
54− content = result['artist']['name'] +\
55+ result['artist']['name'],
55− " &bull; " +\
56− result['album']['title'] +\
56+ result['album']['title'],
57− " &bull; " + result['title']
57+ result['title'])
58+
58 embedded = embedded_url.format(audioid=result['id'])
59 embedded = embedded_url.format(audioid=result['id'])
59
60
60 # append result
61 # append result
searx/engines/dictzone.py+2−3
@@ -12,7 +12,6 @@
12import re
12import re
13from urlparse import urljoin
13from urlparse import urljoin
14from lxml import html
14from lxml import html
15−from cgi import escape
16from searx.utils import is_valid_lang
15from searx.utils import is_valid_lang
17
16
18categories = ['general']
17categories = ['general']
@@ -62,8 +61,8 @@ def response(resp):
62
61
63 results.append({
62 results.append({
64 'url': urljoin(resp.url, '?%d' % k),
63 'url': urljoin(resp.url, '?%d' % k),
65− 'title': escape(from_result.text_content()),
64+ 'title': from_result.text_content(),
66− 'content': escape('; '.join(to_results))
65+ 'content': '; '.join(to_results)
67 })
66 })
68
67
69 return results
68 return results
searx/engines/digg.py+1−2
@@ -13,7 +13,6 @@
13from urllib import quote_plus
13from urllib import quote_plus
14from json import loads
14from json import loads
15from lxml import html
15from lxml import html
16−from cgi import escape
17from dateutil import parser
16from dateutil import parser
18
17
19# engine dependent config
18# engine dependent config
@@ -56,7 +55,7 @@ def response(resp):
56 url = result.attrib.get('data-contenturl')
55 url = result.attrib.get('data-contenturl')
57 thumbnail = result.xpath('.//img')[0].attrib.get('src')
56 thumbnail = result.xpath('.//img')[0].attrib.get('src')
58 title = ''.join(result.xpath(title_xpath))
57 title = ''.join(result.xpath(title_xpath))
59− content = escape(''.join(result.xpath(content_xpath)))
58+ content = ''.join(result.xpath(content_xpath))
60 pubdate = result.xpath(pubdate_xpath)[0].attrib.get('datetime')
59 pubdate = result.xpath(pubdate_xpath)[0].attrib.get('datetime')
61 publishedDate = parser.parse(pubdate)
60 publishedDate = parser.parse(pubdate)
62
61
searx/engines/fdroid.py+1−2
@@ -9,7 +9,6 @@
9 @parse url, title, content
9 @parse url, title, content
10"""
10"""
11
11
12−from cgi import escape
13from urllib import urlencode
12from urllib import urlencode
14from searx.engines.xpath import extract_text
13from searx.engines.xpath import extract_text
15from lxml import html
14from lxml import html
@@ -43,7 +42,7 @@ def response(resp):
43 img_src = app.xpath('.//img/@src')[0]
42 img_src = app.xpath('.//img/@src')[0]
44
43
45 content = extract_text(app.xpath('./p')[0])
44 content = extract_text(app.xpath('./p')[0])
46− content = escape(content.replace(title, '', 1).strip())
45+ content = content.replace(title, '', 1).strip()
47
46
48 results.append({'url': url,
47 results.append({'url': url,
49 'title': title,
48 'title': title,
searx/engines/flickr.py+3−11
@@ -77,21 +77,13 @@ def response(resp):
77
77
78 url = build_flickr_url(photo['owner'], photo['id'])
78 url = build_flickr_url(photo['owner'], photo['id'])
79
79
80− title = photo['title']
81−
82− content = '<span class="photo-author">' +\
83− photo['ownername'] +\
84− '</span><br />' +\
85− '<span class="description">' +\
86− photo['description']['_content'] +\
87− '</span>'
88−
89 # append result
80 # append result
90 results.append({'url': url,
81 results.append({'url': url,
91− 'title': title,
82+ 'title': photo['title'],
92 'img_src': img_src,
83 'img_src': img_src,
93 'thumbnail_src': thumbnail_src,
84 'thumbnail_src': thumbnail_src,
94− 'content': content,
85+ 'content': content = photo['description']['_content'],
86+ 'author': photo['ownername'],
95 'template': 'images.html'})
87 'template': 'images.html'})
96
88
97 # return results
89 # return results
searx/engines/flickr_noapi.py+3−4
@@ -102,16 +102,15 @@ def response(resp):
102
102
103 title = photo.get('title', '')
103 title = photo.get('title', '')
104
104
105− content = '<span class="photo-author">' +\
106− photo['username'] +\
105+ author = photo['username']
107− '</span><br />'
108
106
109 # append result
107 # append result
110 results.append({'url': url,
108 results.append({'url': url,
111 'title': title,
109 'title': title,
112 'img_src': img_src,
110 'img_src': img_src,
113 'thumbnail_src': thumbnail_src,
111 'thumbnail_src': thumbnail_src,
114− 'content': content,
112+ 'content': '',
113+ 'author': author,
115 'template': 'images.html'})
114 'template': 'images.html'})
116
115
117 return results
116 return results
searx/engines/gigablast.py+2−3
@@ -10,7 +10,6 @@
10 @parse url, title, content
10 @parse url, title, content
11"""
11"""
12
12
13−from cgi import escape
14from json import loads
13from json import loads
15from random import randint
14from random import randint
16from time import time
15from time import time
@@ -78,8 +77,8 @@ def response(resp):
78 for result in response_json['results']:
77 for result in response_json['results']:
79 # append result
78 # append result
80 results.append({'url': result['url'],
79 results.append({'url': result['url'],
81− 'title': escape(result['title']),
80+ 'title': result['title'],
82− 'content': escape(result['sum'])})
81+ 'content': result['sum']})
83
82
84 # return results
83 # return results
85 return results
84 return results
searx/engines/github.py+1−2
@@ -12,7 +12,6 @@
12
12
13from urllib import urlencode
13from urllib import urlencode
14from json import loads
14from json import loads
15−from cgi import escape
16
15
17# engine dependent config
16# engine dependent config
18categories = ['it']
17categories = ['it']
@@ -48,7 +47,7 @@ def response(resp):
48 url = res['html_url']
47 url = res['html_url']
49
48
50 if res['description']:
49 if res['description']:
51− content = escape(res['description'][:500])
50+ content = res['description'][:500]
52 else:
51 else:
53 content = ''
52 content = ''
54
53
searx/engines/google.py+2−3
@@ -9,7 +9,6 @@
9# @parse url, title, content, suggestion
9# @parse url, title, content, suggestion
10
10
11import re
11import re
12−from cgi import escape
13from urllib import urlencode
12from urllib import urlencode
14from urlparse import urlparse, parse_qsl
13from urlparse import urlparse, parse_qsl
15from lxml import html, etree
14from lxml import html, etree
@@ -155,7 +154,7 @@ def parse_url(url_string, google_hostname):
155def extract_text_from_dom(result, xpath):
154def extract_text_from_dom(result, xpath):
156 r = result.xpath(xpath)
155 r = result.xpath(xpath)
157 if len(r) > 0:
156 if len(r) > 0:
158− return escape(extract_text(r[0]))
157+ return extract_text(r[0])
159 return None
158 return None
160
159
161
160
@@ -264,7 +263,7 @@ def response(resp):
264 # parse suggestion
263 # parse suggestion
265 for suggestion in dom.xpath(suggestion_xpath):
264 for suggestion in dom.xpath(suggestion_xpath):
266 # append suggestion
265 # append suggestion
267− results.append({'suggestion': escape(extract_text(suggestion))})
266+ results.append({'suggestion': extract_text(suggestion)})
268
267
269 # return results
268 # return results
270 return results
269 return results
searx/engines/kickass.py+1−2
@@ -11,7 +11,6 @@
11"""
11"""
12
12
13from urlparse import urljoin
13from urlparse import urljoin
14−from cgi import escape
15from urllib import quote
14from urllib import quote
16from lxml import html
15from lxml import html
17from operator import itemgetter
16from operator import itemgetter
@@ -57,7 +56,7 @@ def response(resp):
57 link = result.xpath('.//a[@class="cellMainLink"]')[0]
56 link = result.xpath('.//a[@class="cellMainLink"]')[0]
58 href = urljoin(url, link.attrib['href'])
57 href = urljoin(url, link.attrib['href'])
59 title = extract_text(link)
58 title = extract_text(link)
60− content = escape(extract_text(result.xpath(content_xpath)))
59+ content = extract_text(result.xpath(content_xpath))
61 seed = extract_text(result.xpath('.//td[contains(@class, "green")]'))
60 seed = extract_text(result.xpath('.//td[contains(@class, "green")]'))
62 leech = extract_text(result.xpath('.//td[contains(@class, "red")]'))
61 leech = extract_text(result.xpath('.//td[contains(@class, "red")]'))
63 filesize_info = extract_text(result.xpath('.//td[contains(@class, "nobr")]'))
62 filesize_info = extract_text(result.xpath('.//td[contains(@class, "nobr")]'))
searx/engines/nyaa.py+2−4
@@ -9,7 +9,6 @@
9 @parse url, title, content, seed, leech, torrentfile
9 @parse url, title, content, seed, leech, torrentfile
10"""
10"""
11
11
12−from cgi import escape
13from urllib import urlencode
12from urllib import urlencode
14from lxml import html
13from lxml import html
15from searx.engines.xpath import extract_text
14from searx.engines.xpath import extract_text
@@ -78,7 +77,7 @@ def response(resp):
78
77
79 # torrent title
78 # torrent title
80 page_a = result.xpath(xpath_title)[0]
79 page_a = result.xpath(xpath_title)[0]
81− title = escape(extract_text(page_a))
80+ title = extract_text(page_a)
82
81
83 # link to the page
82 # link to the page
84 href = page_a.attrib.get('href')
83 href = page_a.attrib.get('href')
@@ -90,7 +89,7 @@ def response(resp):
90 try:
89 try:
91 file_size, suffix = result.xpath(xpath_filesize)[0].split(' ')
90 file_size, suffix = result.xpath(xpath_filesize)[0].split(' ')
92 file_size = int(float(file_size) * get_filesize_mul(suffix))
91 file_size = int(float(file_size) * get_filesize_mul(suffix))
93− except Exception as e:
92+ except:
94 file_size = None
93 file_size = None
95
94
96 # seed count
95 # seed count
@@ -105,7 +104,6 @@ def response(resp):
105 # content string contains all information not included into template
104 # content string contains all information not included into template
106 content = 'Category: "{category}". Downloaded {downloads} times.'
105 content = 'Category: "{category}". Downloaded {downloads} times.'
107 content = content.format(category=category, downloads=downloads)
106 content = content.format(category=category, downloads=downloads)
108− content = escape(content)
109
107
110 results.append({'url': href,
108 results.append({'url': href,
111 'title': title,
109 'title': title,
searx/engines/piratebay.py+1−2
@@ -9,7 +9,6 @@
9# @parse url, title, content, seed, leech, magnetlink
9# @parse url, title, content, seed, leech, magnetlink
10
10
11from urlparse import urljoin
11from urlparse import urljoin
12−from cgi import escape
13from urllib import quote
12from urllib import quote
14from lxml import html
13from lxml import html
15from operator import itemgetter
14from operator import itemgetter
@@ -62,7 +61,7 @@ def response(resp):
62 link = result.xpath('.//div[@class="detName"]//a')[0]
61 link = result.xpath('.//div[@class="detName"]//a')[0]
63 href = urljoin(url, link.attrib.get('href'))
62 href = urljoin(url, link.attrib.get('href'))
64 title = extract_text(link)
63 title = extract_text(link)
65− content = escape(extract_text(result.xpath(content_xpath)))
64+ content = extract_text(result.xpath(content_xpath))
66 seed, leech = result.xpath('.//td[@align="right"]/text()')[:2]
65 seed, leech = result.xpath('.//td[@align="right"]/text()')[:2]
67
66
68 # convert seed to int if possible
67 # convert seed to int if possible
searx/engines/reddit.py+1−2
@@ -11,7 +11,6 @@
11"""
11"""
12
12
13import json
13import json
14−from cgi import escape
15from urllib import urlencode
14from urllib import urlencode
16from urlparse import urlparse, urljoin
15from urlparse import urlparse, urljoin
17from datetime import datetime
16from datetime import datetime
@@ -68,7 +67,7 @@ def response(resp):
68 img_results.append(params)
67 img_results.append(params)
69 else:
68 else:
70 created = datetime.fromtimestamp(data['created_utc'])
69 created = datetime.fromtimestamp(data['created_utc'])
71− content = escape(data['selftext'])
70+ content = data['selftext']
72 if len(content) > 500:
71 if len(content) > 500:
73 content = content[:500] + '...'
72 content = content[:500] + '...'
74 params['content'] = content
73 params['content'] = content
searx/engines/searchcode_doc.py+2−10
@@ -44,20 +44,12 @@ def response(resp):
44 # parse results
44 # parse results
45 for result in search_results.get('results', []):
45 for result in search_results.get('results', []):
46 href = result['url']
46 href = result['url']
47− title = "[" + result['type'] + "] " +\
47+ title = "[{}] {} {}".format(result['type'], result['namespace'], result['name'])
48− result['namespace'] +\
49− " " + result['name']
50− content = '<span class="highlight">[' +\
51− result['type'] + "] " +\
52− result['name'] + " " +\
53− result['synopsis'] +\
54− "</span><br />" +\
55− result['description']
56
48
57 # append result
49 # append result
58 results.append({'url': href,
50 results.append({'url': href,
59 'title': title,
51 'title': title,
60− 'content': content})
52+ 'content': result['description']})
61
53
62 # return results
54 # return results
63 return results
55 return results
searx/engines/seedpeer.py−1
@@ -9,7 +9,6 @@
9# @parse url, title, content, seed, leech, magnetlink
9# @parse url, title, content, seed, leech, magnetlink
10
10
11from urlparse import urljoin
11from urlparse import urljoin
12−from cgi import escape
13from urllib import quote
12from urllib import quote
14from lxml import html
13from lxml import html
15from operator import itemgetter
14from operator import itemgetter
searx/engines/spotify.py+5−4
@@ -46,10 +46,11 @@ def response(resp):
46 if result['type'] == 'track':
46 if result['type'] == 'track':
47 title = result['name']
47 title = result['name']
48 url = result['external_urls']['spotify']
48 url = result['external_urls']['spotify']
49+ content = '{} - {} - {}'.format(
49− content = result['artists'][0]['name'] +\
50+ result['artists'][0]['name'],
50− " &bull; " +\
51− result['album']['name'] +\
51+ result['album']['name'],
52− " &bull; " + result['name']
52+ result['name'])
53+
53 embedded = embedded_url.format(audioid=result['id'])
54 embedded = embedded_url.format(audioid=result['id'])
54
55
55 # append result
56 # append result
searx/engines/stackoverflow.py+2−3
@@ -11,7 +11,6 @@
11"""
11"""
12
12
13from urlparse import urljoin
13from urlparse import urljoin
14−from cgi import escape
15from urllib import urlencode
14from urllib import urlencode
16from lxml import html
15from lxml import html
17from searx.engines.xpath import extract_text
16from searx.engines.xpath import extract_text
@@ -48,8 +47,8 @@ def response(resp):
48 for result in dom.xpath(results_xpath):
47 for result in dom.xpath(results_xpath):
49 link = result.xpath(link_xpath)[0]
48 link = result.xpath(link_xpath)[0]
50 href = urljoin(url, link.attrib.get('href'))
49 href = urljoin(url, link.attrib.get('href'))
51− title = escape(extract_text(link))
50+ title = extract_text(link)
52− content = escape(extract_text(result.xpath(content_xpath)))
51+ content = extract_text(result.xpath(content_xpath))
53
52
54 # append result
53 # append result
55 results.append({'url': href,
54 results.append({'url': href,
searx/engines/startpage.py+2−3
@@ -11,7 +11,6 @@
11# @todo paging
11# @todo paging
12
12
13from lxml import html
13from lxml import html
14−from cgi import escape
15from dateutil import parser
14from dateutil import parser
16from datetime import datetime, timedelta
15from datetime import datetime, timedelta
17import re
16import re
@@ -79,10 +78,10 @@ def response(resp):
79 if re.match(r"^http(s|)://(www\.)?ixquick\.com/do/search\?.*$", url):
78 if re.match(r"^http(s|)://(www\.)?ixquick\.com/do/search\?.*$", url):
80 continue
79 continue
81
80
82− title = escape(extract_text(link))
81+ title = extract_text(link)
83
82
84 if result.xpath('./p[@class="desc clk"]'):
83 if result.xpath('./p[@class="desc clk"]'):
85− content = escape(extract_text(result.xpath('./p[@class="desc clk"]')))
84+ content = extract_text(result.xpath('./p[@class="desc clk"]'))
86 else:
85 else:
87 content = ''
86 content = ''
88
87
searx/engines/subtitleseeker.py+2−3
@@ -10,7 +10,6 @@
10 @parse url, title, content
10 @parse url, title, content
11"""
11"""
12
12
13−from cgi import escape
14from urllib import quote_plus
13from urllib import quote_plus
15from lxml import html
14from lxml import html
16from searx.languages import language_codes
15from searx.languages import language_codes
@@ -59,7 +58,7 @@ def response(resp):
59 elif search_lang:
58 elif search_lang:
60 href = href + search_lang + '/'
59 href = href + search_lang + '/'
61
60
62− title = escape(extract_text(link))
61+ title = extract_text(link)
63
62
64 content = extract_text(result.xpath('.//div[contains(@class,"red")]'))
63 content = extract_text(result.xpath('.//div[contains(@class,"red")]'))
65 content = content + " - "
64 content = content + " - "
@@ -75,7 +74,7 @@ def response(resp):
75 # append result
74 # append result
76 results.append({'url': href,
75 results.append({'url': href,
77 'title': title,
76 'title': title,
78− 'content': escape(content)})
77+ 'content': content})
79
78
80 # return results
79 # return results
81 return results
80 return results
searx/engines/swisscows.py+4−5
@@ -10,7 +10,6 @@
10 @parse url, title, content
10 @parse url, title, content
11"""
11"""
12
12
13−from cgi import escape
14from json import loads
13from json import loads
15from urllib import urlencode, unquote
14from urllib import urlencode, unquote
16import re
15import re
@@ -78,7 +77,7 @@ def response(resp):
78
77
79 # append result
78 # append result
80 results.append({'url': result['SourceUrl'],
79 results.append({'url': result['SourceUrl'],
81− 'title': escape(result['Title']),
80+ 'title': result['Title'],
82 'content': '',
81 'content': '',
83 'img_src': img_url,
82 'img_src': img_url,
84 'template': 'images.html'})
83 'template': 'images.html'})
@@ -90,8 +89,8 @@ def response(resp):
90
89
91 # append result
90 # append result
92 results.append({'url': result_url,
91 results.append({'url': result_url,
93− 'title': escape(result_title),
92+ 'title': result_title,
94− 'content': escape(result_content)})
93+ 'content': result_content})
95
94
96 # parse images
95 # parse images
97 for result in json.get('Images', []):
96 for result in json.get('Images', []):
@@ -100,7 +99,7 @@ def response(resp):
100
99
101 # append result
100 # append result
102 results.append({'url': result['SourceUrl'],
101 results.append({'url': result['SourceUrl'],
103− 'title': escape(result['Title']),
102+ 'title': result['Title'],
104 'content': '',
103 'content': '',
105 'img_src': img_url,
104 'img_src': img_url,
106 'template': 'images.html'})
105 'template': 'images.html'})
searx/engines/tokyotoshokan.py−1
@@ -11,7 +11,6 @@
11"""
11"""
12
12
13import re
13import re
14−from cgi import escape
15from urllib import urlencode
14from urllib import urlencode
16from lxml import html
15from lxml import html
17from searx.engines.xpath import extract_text
16from searx.engines.xpath import extract_text
searx/engines/torrentz.py−1
@@ -12,7 +12,6 @@
12"""
12"""
13
13
14import re
14import re
15−from cgi import escape
16from urllib import urlencode
15from urllib import urlencode
17from lxml import html
16from lxml import html
18from searx.engines.xpath import extract_text
17from searx.engines.xpath import extract_text
searx/engines/translated.py+5−6
@@ -9,7 +9,6 @@
9 @parse url, title, content
9 @parse url, title, content
10"""
10"""
11import re
11import re
12−from cgi import escape
13from searx.utils import is_valid_lang
12from searx.utils import is_valid_lang
14
13
15categories = ['general']
14categories = ['general']
@@ -52,14 +51,14 @@ def request(query, params):
52def response(resp):
51def response(resp):
53 results = []
52 results = []
54 results.append({
53 results.append({
55− 'url': escape(web_url.format(
54+ 'url': web_url.format(
56 from_lang=resp.search_params['from_lang'][2],
55 from_lang=resp.search_params['from_lang'][2],
57 to_lang=resp.search_params['to_lang'][2],
56 to_lang=resp.search_params['to_lang'][2],
58− query=resp.search_params['query'])),
57+ query=resp.search_params['query']),
59− 'title': escape('[{0}-{1}] {2}'.format(
58+ 'title': '[{0}-{1}] {2}'.format(
60 resp.search_params['from_lang'][1],
59 resp.search_params['from_lang'][1],
61 resp.search_params['to_lang'][1],
60 resp.search_params['to_lang'][1],
62− resp.search_params['query'])),
61+ resp.search_params['query']),
63− 'content': escape(resp.json()['responseData']['translatedText'])
62+ 'content': resp.json()['responseData']['translatedText']
64 })
63 })
65 return results
64 return results
searx/engines/wolframalpha_noapi.py−1
@@ -8,7 +8,6 @@
8# @stable no
8# @stable no
9# @parse url, infobox
9# @parse url, infobox
10
10
11−from cgi import escape
12from json import loads
11from json import loads
13from time import time
12from time import time
14from urllib import urlencode
13from urllib import urlencode
searx/engines/yandex.py+2−3
@@ -9,7 +9,6 @@
9 @parse url, title, content
9 @parse url, title, content
10"""
10"""
11
11
12−from cgi import escape
13from urllib import urlencode
12from urllib import urlencode
14from lxml import html
13from lxml import html
15from searx.search import logger
14from searx.search import logger
@@ -52,8 +51,8 @@ def response(resp):
52 for result in dom.xpath(results_xpath):
51 for result in dom.xpath(results_xpath):
53 try:
52 try:
54 res = {'url': result.xpath(url_xpath)[0],
53 res = {'url': result.xpath(url_xpath)[0],
55− 'title': escape(''.join(result.xpath(title_xpath))),
54+ 'title': ''.join(result.xpath(title_xpath)),
56− 'content': escape(''.join(result.xpath(content_xpath)))}
55+ 'content': ''.join(result.xpath(content_xpath))}
57 except:
56 except:
58 logger.exception('yandex parse crash')
57 logger.exception('yandex parse crash')
59 continue
58 continue