Skip to content

Commit

Permalink
Use urllib.parse for quoting/unquoting plus instead of deprecated wer…
Browse files Browse the repository at this point in the history
…kzeug.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.
  • Loading branch information
vin01 authored Dec 2, 2023
1 parent 8103cb4 commit ae27473
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions snappass/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
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')))
Expand Down Expand Up @@ -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:
Expand All @@ -185,7 +185,7 @@ def handle_password():

@app.route('/<password_key>', 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

Expand All @@ -194,7 +194,7 @@ def preview_password(password_key):

@app.route('/<password_key>', 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
Expand Down

0 comments on commit ae27473

Please sign in to comment.