Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions flask_images/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
from PIL import Image, ImageFilter
from flask import request, current_app, send_file, abort

try:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to keep the import of Signer

from itsdangerous import Signer, constant_time_compare
except ImportError:
from itsdangerous import Signer
from itsdangerous._compat import constant_time_compare
from hmac import compare_digest

from . import modes
from .size import ImageSize
Expand Down Expand Up @@ -307,7 +303,7 @@ def handle_request(self, path):
abort(404)
signer = Signer(current_app.secret_key)
new_sig = signer.get_signature('%s?%s' % (path, urlencode(sorted(iteritems(query)), True)))
if not constant_time_compare(str(old_sig), str(new_sig.decode('utf-8'))):
if not compare_digest(str(old_sig), str(new_sig.decode('utf-8'))):
log.warning("Signature mismatch: url's {} != expected {}".format(old_sig, new_sig))
abort(404)

Expand Down