Use werkzeug quote/unquote functions instead of urllib
This commit is contained in:
parent
9e7ca474cd
commit
13f294cae5
1 changed files with 4 additions and 7 deletions
|
@ -1,11 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
# Support python2 and python3 quote import
|
|
||||||
try:
|
|
||||||
from urllib import quote, unquote
|
|
||||||
except ImportError:
|
|
||||||
from urllib.parse import quote, unquote
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import redis
|
import redis
|
||||||
|
@ -13,6 +8,8 @@ import redis
|
||||||
from cryptography.fernet import Fernet
|
from cryptography.fernet import Fernet
|
||||||
from flask import abort, Flask, render_template, request
|
from flask import abort, Flask, render_template, request
|
||||||
from redis.exceptions import ConnectionError
|
from redis.exceptions import ConnectionError
|
||||||
|
from werkzeug.urls import url_quote_plus
|
||||||
|
from werkzeug.urls import url_unquote_plus
|
||||||
|
|
||||||
|
|
||||||
SNEAKY_USER_AGENTS = ('Slackbot', 'facebookexternalhit', 'Twitterbot',
|
SNEAKY_USER_AGENTS = ('Slackbot', 'facebookexternalhit', 'Twitterbot',
|
||||||
|
@ -170,7 +167,7 @@ def handle_password():
|
||||||
base_url = request.url_root
|
base_url = request.url_root
|
||||||
else:
|
else:
|
||||||
base_url = request.url_root.replace("http://", "https://")
|
base_url = request.url_root.replace("http://", "https://")
|
||||||
link = base_url + quote(token)
|
link = base_url + url_quote_plus(token)
|
||||||
return render_template('confirm.html', password_link=link)
|
return render_template('confirm.html', password_link=link)
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,7 +175,7 @@ def handle_password():
|
||||||
def show_password(password_key):
|
def show_password(password_key):
|
||||||
if not request_is_valid(request):
|
if not request_is_valid(request):
|
||||||
abort(404)
|
abort(404)
|
||||||
password_key = unquote(password_key)
|
password_key = url_unquote_plus(password_key)
|
||||||
password = get_password(password_key)
|
password = get_password(password_key)
|
||||||
if not password:
|
if not password:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
Loading…
Reference in a new issue