From ae2747311ae1c1f0171cc86bb909b12bf7e756ad Mon Sep 17 00:00:00 2001 From: vin01 <30344579+vin01@users.noreply.github.com> Date: Sat, 2 Dec 2023 02:54:51 +0100 Subject: [PATCH] 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. --- snappass/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/snappass/main.py b/snappass/main.py index 00c4d01..50b51f0 100644 --- a/snappass/main.py +++ b/snappass/main.py @@ -7,8 +7,8 @@ import redis from cryptography.fernet import Fernet from flask import abort, Flask, render_template, request, jsonify from redis.exceptions import ConnectionError -from werkzeug.urls import url_quote_plus -from werkzeug.urls import url_unquote_plus +from urllib.parse import quote_plus +from urllib.parse import unquote_plus from distutils.util import strtobool 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://") if URL_PREFIX: 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: return jsonify(link=link, ttl=ttl) else: @@ -185,7 +185,7 @@ def handle_password(): @app.route('/', methods=['GET']) def preview_password(password_key): - password_key = url_unquote_plus(password_key) + password_key = unquote_plus(password_key) if not password_exists(password_key): return render_template('expired.html'), 404 @@ -194,7 +194,7 @@ def preview_password(password_key): @app.route('/', methods=['POST']) def show_password(password_key): - password_key = url_unquote_plus(password_key) + password_key = unquote_plus(password_key) password = get_password(password_key) if not password: return render_template('expired.html'), 404