py2 and py3 support

This commit is contained in:
Nicholas Charriere 2018-05-06 15:07:01 -07:00
parent 5a0beb1a75
commit 9e7ca474cd

View file

@ -1,7 +1,11 @@
import os import os
import re import re
import sys import sys
import urllib # 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
@ -166,7 +170,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 + urllib.quote(token) link = base_url + quote(token)
return render_template('confirm.html', password_link=link) return render_template('confirm.html', password_link=link)
@ -174,7 +178,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 = urllib.unquote(password_key) password_key = unquote(password_key)
password = get_password(password_key) password = get_password(password_key)
if not password: if not password:
abort(404) abort(404)