fix: regex in page renderer
This commit is contained in:
@@ -31,7 +31,7 @@ def get_profile_url_prefix():
|
||||
hooks = frappe.get_hooks("profile_url_prefix") or ["/users/"]
|
||||
return hooks[-1]
|
||||
|
||||
RE_USERNAME = re.compile("[a-zA-Z0-9_]{4,}")
|
||||
RE_INVALID_USERNAME = re.compile("[@!#$%^&*()<>?/\\|}{~:-]")
|
||||
|
||||
class ProfileRedirectPage(BaseRenderer):
|
||||
"""Renderer to redirect /profile_/foo to <profile_prefix>/foo.
|
||||
@@ -63,9 +63,8 @@ class ProfilePage(BaseRenderer):
|
||||
|
||||
# not a userpage?
|
||||
username = self.get_username()
|
||||
if not RE_USERNAME.match(username):
|
||||
if RE_INVALID_USERNAME.search(username):
|
||||
return False
|
||||
|
||||
# if there is prefix then we can allow all usernames
|
||||
if prefix:
|
||||
return True
|
||||
|
||||
@@ -10,7 +10,6 @@ def get_context(context):
|
||||
except KeyError:
|
||||
username = frappe.db.get_value("User", frappe.session.user, ["username"])
|
||||
if username:
|
||||
print(username)
|
||||
frappe.local.flags.redirect_location = get_profile_url_prefix() + urlencode({"username": username})
|
||||
raise frappe.Redirect
|
||||
try:
|
||||
@@ -18,7 +17,6 @@ def get_context(context):
|
||||
except:
|
||||
context.template = "www/404.html"
|
||||
return
|
||||
print(context.member)
|
||||
context.profile_tabs = get_profile_tabs(context.member)
|
||||
|
||||
def get_profile_tabs(user):
|
||||
|
||||
Reference in New Issue
Block a user