From bde9531ff38d0e6de420529b666e883b9fcfc937 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 26 Feb 2022 17:22:18 +0200 Subject: [PATCH] cyrillic --- files/helpers/const.py | 5 ++++- files/helpers/sanitize.py | 2 +- files/routes/login.py | 2 -- files/routes/settings.py | 5 ++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index c1d53ef16..9d80bec87 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -666,4 +666,7 @@ christian_emojis = (':#marseyjesus:',':#marseyimmaculate:',':#marseymothermary:' db = db_session() marseys_const = [x[0] for x in db.query(Marsey.name).all()] + ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','exclamationpoint','period','questionmark'] -db.close() \ No newline at end of file +db.close() + +if SITE == 'PCM': valid_username_regex = re.compile("^[a-zA-Z0-9_\-А-я]{3,25}$") +else: valid_username_regex = re.compile("^[a-zA-Z0-9_\-]{3,25}$") \ No newline at end of file diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 1eae6bacf..e55026e40 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -181,7 +181,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): tag["target"] = "_blank" tag["rel"] = "nofollow noopener noreferrer" - if re.match("https?://\S+", str(tag.string), flags=re.A): + if re.fullmatch("https?://\S+", str(tag.string), flags=re.A): try: tag.string = tag["href"] except: tag.string = "" diff --git a/files/routes/login.py b/files/routes/login.py index cd1084282..3d4919920 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -4,10 +4,8 @@ from files.__main__ import app, limiter from files.helpers.const import * import requests -valid_username_regex = re.compile("^[a-zA-Z0-9_\-]{3,25}$") valid_password_regex = re.compile("^.{8,100}$") - @app.get("/login") @auth_desired def login_get(v): diff --git a/files/routes/settings.py b/files/routes/settings.py index b99eec2af..13aa3a3da 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -14,7 +14,6 @@ from files.helpers.discord import add_role from shutil import copyfile import requests -valid_username_regex = re.compile("^[a-zA-Z0-9_\-]{3,25}$") valid_password_regex = re.compile("^.{8,100}$") YOUTUBE_KEY = environ.get("YOUTUBE_KEY", "").strip() @@ -533,7 +532,7 @@ def settings_security_post(v): if request.values.get("new_password") != request.values.get("cnf_password"): return render_template("settings_security.html", v=v, error="Passwords do not match.") - if not re.match(valid_password_regex, request.values.get("new_password")): + if not re.fullmatch(valid_password_regex, request.values.get("new_password")): return render_template("settings_security.html", v=v, error="Password must be between 8 and 100 characters.") if not v.verifyPass(request.values.get("old_password")): @@ -860,7 +859,7 @@ def settings_name_change(v): v=v, error="You didn't change anything") - if not re.match(valid_username_regex, new_name): + if not re.fullmatch(valid_username_regex, new_name): return render_template("settings_profile.html", v=v, error="This isn't a valid username.")