Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use urllib.parse for quoting/unquoting plus instead of deprecated werkzeug.urls #300

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Changes from all commits
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
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