summaryrefslogtreecommitdiffstats
path: root/utils.py
diff options
context:
space:
mode:
authorNico von Geyso <Nico.Geyso@FU-Berlin.de>2012-10-29 18:36:17 +0100
committerNico von Geyso <Nico.Geyso@FU-Berlin.de>2012-10-29 18:36:17 +0100
commit1b27fe03a87aad1ed693d6197633c7ade2e68a1f (patch)
tree774d5d69a2c10b03792d8e749548848d9508ccb2 /utils.py
parentc5823c2473a5301f4799e41717a21c8d5ab56466 (diff)
parent815df16283c6332c1c4ba9d129fd745cabf57315 (diff)
downloadweb-1b27fe03a87aad1ed693d6197633c7ade2e68a1f.tar.gz
web-1b27fe03a87aad1ed693d6197633c7ade2e68a1f.tar.bz2
web-1b27fe03a87aad1ed693d6197633c7ade2e68a1f.zip
Merge branch 'master' of ssh://git.spline.de/account-web
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