summaryrefslogtreecommitdiffstats
path: root/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/utils.py b/utils.py
index 595f770..ca0fb16 100644
--- a/utils.py
+++ b/utils.py
@@ -20,7 +20,7 @@ from wtforms.validators import Regexp
-_username_re = re.compile(r'^[a-zA-Z][a-zA-Z0-9-]{1,15}')
+_username_re = re.compile(r'^[a-zA-Z][a-zA-Z0-9-]{1,15}$')
_username_exclude_re = re.compile(r'^(admin|root)')
# using http://flask.pocoo.org/docs/patterns/viewdecorators/
@@ -234,7 +234,8 @@ def url_for(endpoint, **values):
"""Wrap `flask.url_for` so that it always returns https links"""
#XXX: Drop this in favor of config.PREFERRED_URL_SCHEME when we require Flask 0.9
u = flask_url_for(endpoint, **values)
- if '_external' in values and u.startswith('http://'):
+ if '_external' in values and u.startswith('http://') \
+ and current_app.config['PREFERRED_URL_SCHEME'] == 'https':
return 'https://' + u[7:]
else:
return u