mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Don't double encode base64 images for widgets.
This commit is contained in:
parent
00aabee31a
commit
ca728af375
2 changed files with 9 additions and 2 deletions
|
@ -1624,6 +1624,8 @@ def load_river_stories_widget(request):
|
|||
logging.user(request.user, '"%s" not fetched in %ss' % (url, (time.time() - start)))
|
||||
return None
|
||||
data = conn.read()
|
||||
if not url.startswith("data:"):
|
||||
data = base64.b64encode(page['data']).decode('utf-8')
|
||||
logging.user(request.user, '"%s" fetched in %ss' % (url, (time.time() - start)))
|
||||
return dict(url=original_url, data=data)
|
||||
|
||||
|
@ -1641,11 +1643,12 @@ def load_river_stories_widget(request):
|
|||
thumbnail_data = dict()
|
||||
for page in pages:
|
||||
if not page: continue
|
||||
thumbnail_data[page['url']] = base64.b64encode(page['data']).decode('utf-8')
|
||||
thumbnail_data[page['url']] = page['data']
|
||||
for story in river_stories_data['stories']:
|
||||
thumbnail_values = list(story['secure_image_thumbnails'].values())
|
||||
if thumbnail_values and thumbnail_values[0] in thumbnail_data:
|
||||
story['select_thumbnail_data'] = thumbnail_data[thumbnail_values[0]]
|
||||
page_url = thumbnail_values[0]
|
||||
story['select_thumbnail_data'] = thumbnail_data[page_url]
|
||||
|
||||
logging.user(request, ("Elapsed Time: %ss" % (time.time() - start)))
|
||||
|
||||
|
|
|
@ -327,6 +327,10 @@ def create_imageproxy_signed_url(base_url, hmac_key, url, options=None):
|
|||
if not isinstance(options, list): options = [options]
|
||||
if sys.getdefaultencoding() == 'ascii':
|
||||
url = url.encode('utf-8')
|
||||
|
||||
if url.startswith("data:"):
|
||||
return url.rsplit(',', 1)[1]
|
||||
|
||||
base_url = base_url.rstrip('/')
|
||||
signature = base64.urlsafe_b64encode(hmac.new(hmac_key.encode(), msg=url.encode(), digestmod=hashlib.sha256).digest())
|
||||
options.append('sc')
|
||||
|
|
Loading…
Add table
Reference in a new issue