Use urllib.parse for quoting/unquoting plus instead of deprecated werkzeug.urls (#300)
Use urllib.parse for quoting/unquoting plus werkzeug.urls.url_quote_plus and werkzeug.urls.url_unquote_plus were deprecated and are removed in 3.0.0 and newer versions.
This commit is contained in:
parent
8103cb4adb
commit
ae2747311a
1 changed files with 5 additions and 5 deletions
|
@ -7,8 +7,8 @@ import redis
|
||||||
from cryptography.fernet import Fernet
|
from cryptography.fernet import Fernet
|
||||||
from flask import abort, Flask, render_template, request, jsonify
|
from flask import abort, Flask, render_template, request, jsonify
|
||||||
from redis.exceptions import ConnectionError
|
from redis.exceptions import ConnectionError
|
||||||
from werkzeug.urls import url_quote_plus
|
from urllib.parse import quote_plus
|
||||||
from werkzeug.urls import url_unquote_plus
|
from urllib.parse import unquote_plus
|
||||||
from distutils.util import strtobool
|
from distutils.util import strtobool
|
||||||
|
|
||||||
NO_SSL = bool(strtobool(os.environ.get('NO_SSL', 'False')))
|
NO_SSL = bool(strtobool(os.environ.get('NO_SSL', 'False')))
|
||||||
|
@ -176,7 +176,7 @@ def handle_password():
|
||||||
base_url = request.url_root.replace("http://", "https://")
|
base_url = request.url_root.replace("http://", "https://")
|
||||||
if URL_PREFIX:
|
if URL_PREFIX:
|
||||||
base_url = base_url + URL_PREFIX.strip("/") + "/"
|
base_url = base_url + URL_PREFIX.strip("/") + "/"
|
||||||
link = base_url + url_quote_plus(token)
|
link = base_url + quote_plus(token)
|
||||||
if request.accept_mimetypes.accept_json and not request.accept_mimetypes.accept_html:
|
if request.accept_mimetypes.accept_json and not request.accept_mimetypes.accept_html:
|
||||||
return jsonify(link=link, ttl=ttl)
|
return jsonify(link=link, ttl=ttl)
|
||||||
else:
|
else:
|
||||||
|
@ -185,7 +185,7 @@ def handle_password():
|
||||||
|
|
||||||
@app.route('/<password_key>', methods=['GET'])
|
@app.route('/<password_key>', methods=['GET'])
|
||||||
def preview_password(password_key):
|
def preview_password(password_key):
|
||||||
password_key = url_unquote_plus(password_key)
|
password_key = unquote_plus(password_key)
|
||||||
if not password_exists(password_key):
|
if not password_exists(password_key):
|
||||||
return render_template('expired.html'), 404
|
return render_template('expired.html'), 404
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ def preview_password(password_key):
|
||||||
|
|
||||||
@app.route('/<password_key>', methods=['POST'])
|
@app.route('/<password_key>', methods=['POST'])
|
||||||
def show_password(password_key):
|
def show_password(password_key):
|
||||||
password_key = url_unquote_plus(password_key)
|
password_key = unquote_plus(password_key)
|
||||||
password = get_password(password_key)
|
password = get_password(password_key)
|
||||||
if not password:
|
if not password:
|
||||||
return render_template('expired.html'), 404
|
return render_template('expired.html'), 404
|
||||||
|
|
Loading…
Reference in a new issue