diff --git a/README.md b/README.md index 82b1219..947b02a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,8 @@ # infopage -or https://infpg.pythonanywhere.com +or https://infopg.web.app it's like pronouns.page but i made it ### todo * social links * sexuality/gender flags -* 404 page -* embed meta tags -* short url redir -* make displ name default to `x["username"]` \ No newline at end of file diff --git a/_server.py b/_server.py index fcc6fbf..674868b 100644 --- a/_server.py +++ b/_server.py @@ -15,6 +15,16 @@ from werkzeug.middleware.proxy_fix import ProxyFix app = flask.Flask(__name__) +def validate_color(color: str) -> bool: + if len(color) != 7 or color[0] != "#": + return False + + for i in color[1::]: + if i not in "abcdef0123456789": + return False + + return True + def sort_list(l: list[list[str]]) -> list[list[str]]: output = [] for i in l: @@ -128,7 +138,7 @@ def api_account_signup(): except KeyError: flask.abort(400) - if len(username) > 24 or len(username) < 1: + if len(x["username"]) > 24 or len(x["username"]) < 1: flask.abort(400) if len(passhash) != 64: @@ -158,7 +168,7 @@ def api_account_signup(): ensure_file(f"{SAVING_DIRECTORY}tokens/{token}.txt", default_value=username) ensure_file(f"{SAVING_DIRECTORY}{username}.json", default_value=json.dumps({ "username": username, - "display_name": username, + "display_name": x["username"], "description": "", "colors": { "accent": "#ff0000", @@ -192,7 +202,8 @@ def api_account_signup(): ["hot", "3"], ["pretty", "3"], ["sexy", "3"] - ], "relationship": [ + ], + "relationship": [ ["beloved", "3"], ["boyfriend", "3"], ["darling", "3"], @@ -243,13 +254,13 @@ def api_save(): user_data["description"] = x["description"] if "colors" in x: - if "accent" in x["colors"]: + if "accent" in x["colors"] and validate_color(x["colors"]["accent"]): user_data["colors"]["accent"] = x["colors"]["accent"] - if "background" in x["colors"]: + if "background" in x["colors"] and validate_color(x["colors"]["background"]): user_data["colors"]["background"] = x["colors"]["background"] - if "text" in x["colors"]: + if "text" in x["colors"] and validate_color(x["colors"]["text"]): user_data["colors"]["text"] = x["colors"]["text"] if "names" in x: diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000..4f7da04 --- /dev/null +++ b/public/404.html @@ -0,0 +1,16 @@ + + + + + Page not found! + + + + + + + +

Page not found!

+ Log in - Sign up + + diff --git a/public/js/editor.js b/public/js/editor.js index 6055fe5..a669f97 100644 --- a/public/js/editor.js +++ b/public/js/editor.js @@ -88,7 +88,9 @@ fetch("/api/account/self", {
Text color:
Background color:
Accent color:

-
+ + +
`; diff --git a/public/js/user.js b/public/js/user.js index f95645a..c336803 100644 --- a/public/js/user.js +++ b/public/js/user.js @@ -12,7 +12,7 @@ function addToOutput(starting, json, key, title) { let x2 = window.location.href.split("?")[0].split("/"); -fetch("/api/account/info/" + x2[x2.length - 1], { +fetch("/api/account/info/" + x2[x2.length - 1].toLowerCase(), { "method": "GET" }).then((response) => (response.json())) .then((json) => { diff --git a/public/user.html b/public/user.html index 412e686..7c58f5b 100644 --- a/public/user.html +++ b/public/user.html @@ -2,7 +2,7 @@ - sussy among us imposter + User not found! @@ -13,4 +13,4 @@ - \ No newline at end of file +