Commit 18f6bbd2 authored by Nivesh Krishna's avatar Nivesh Krishna
Browse files

Merge branch 'fix-errors' into 'master'

fix erros reported on gitlab

Closes #89, #87, and #86

See merge request !133
parents 9e5edcb6 caeafff4
...@@ -47,6 +47,7 @@ def request(query, params): ...@@ -47,6 +47,7 @@ def request(query, params):
try: try:
lang, region = params['language'].split('-') lang, region = params['language'].split('-')
except: except:
lang = 'en'
region = 'us' region = 'us'
if not params['engine_data'].get('next_page_token'): if not params['engine_data'].get('next_page_token'):
params['url'] = search_url.format(query=quote_plus(query), page=params['pageno'], region=region, lang=lang) params['url'] = search_url.format(query=quote_plus(query), page=params['pageno'], region=region, lang=lang)
......
...@@ -368,6 +368,9 @@ def proxify(url): ...@@ -368,6 +368,9 @@ def proxify(url):
def image_proxify(url): def image_proxify(url):
if not isinstance(url, str):
return None
if url.startswith('//'): if url.startswith('//'):
url = 'https:' + url url = 'https:' + url
...@@ -1008,6 +1011,8 @@ def image_proxy(): ...@@ -1008,6 +1011,8 @@ def image_proxy():
max_redirects=20) max_redirects=20)
resp = next(stream) resp = next(stream)
if resp is None:
return '', 400
content_length = resp.headers.get('Content-Length') content_length = resp.headers.get('Content-Length')
if content_length and content_length.isdigit() and int(content_length) > maximum_size: if content_length and content_length.isdigit() and int(content_length) > maximum_size:
return 'Max size', 400 return 'Max size', 400
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment