From 3892a38212c27b88ec27b7d9b326912180c4c0d9 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Dec 2021 21:33:04 +0200 Subject: [PATCH 02/16] dsffds --- files/templates/authforms.html | 4 ++-- files/templates/default.html | 4 ++-- files/templates/log.html | 4 ++-- files/templates/login_2fa.html | 2 +- files/templates/settings.html | 2 +- files/templates/settings2.html | 4 ++-- files/templates/sign_up.html | 2 +- files/templates/sign_up_failed_ref.html | 2 +- files/templates/submit.html | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 7f3535bf4..52e9d9547 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -13,11 +13,11 @@ {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/default.html b/files/templates/default.html index 4715df385..ee22faccc 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -4,12 +4,12 @@ {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/log.html b/files/templates/log.html index 3dca852e4..56f7483d5 100644 --- a/files/templates/log.html +++ b/files/templates/log.html @@ -6,11 +6,11 @@ {% block content %} {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %}
diff --git a/files/templates/login_2fa.html b/files/templates/login_2fa.html index a1b4dfb76..28f6d791b 100644 --- a/files/templates/login_2fa.html +++ b/files/templates/login_2fa.html @@ -12,7 +12,7 @@ 2-Step Login - {{'SITE_NAME' | app_config}} - + diff --git a/files/templates/settings.html b/files/templates/settings.html index 8453c8668..582379b3a 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -31,7 +31,7 @@ - + {% if v.agendaposter %}{% elif v.css %}{% endif %} diff --git a/files/templates/settings2.html b/files/templates/settings2.html index 836a5defa..7652899c6 100644 --- a/files/templates/settings2.html +++ b/files/templates/settings2.html @@ -36,10 +36,10 @@ {% if v %} - + {% else %} - + {% endif %} diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index e52a3c3fb..41549f5e0 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -28,7 +28,7 @@ {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}Sign up - {{'SITE_NAME' | app_config}}{% endif %} - + diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index bb424ceca..7c6afe350 100644 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -29,7 +29,7 @@ {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}{{'SITE_NAME' | app_config}}{% endif %} - + diff --git a/files/templates/submit.html b/files/templates/submit.html index f0ac63b25..3eef78be2 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -23,11 +23,11 @@ {% block stylesheets %} {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} {% endblock %} From e6403bfa264983a609a409032550298f6b3d80ed Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Dec 2021 21:35:04 +0200 Subject: [PATCH 03/16] fdsfds --- files/templates/authforms.html | 4 ++-- files/templates/default.html | 4 ++-- files/templates/log.html | 4 ++-- files/templates/login_2fa.html | 2 +- files/templates/settings.html | 2 +- files/templates/settings2.html | 4 ++-- files/templates/sign_up.html | 2 +- files/templates/sign_up_failed_ref.html | 2 +- files/templates/submit.html | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 52e9d9547..912e01895 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -13,11 +13,11 @@ {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/default.html b/files/templates/default.html index ee22faccc..ead207b7b 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -4,12 +4,12 @@ {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/log.html b/files/templates/log.html index 56f7483d5..454bbfa82 100644 --- a/files/templates/log.html +++ b/files/templates/log.html @@ -6,11 +6,11 @@ {% block content %} {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %}
diff --git a/files/templates/login_2fa.html b/files/templates/login_2fa.html index 28f6d791b..cd68a5cf6 100644 --- a/files/templates/login_2fa.html +++ b/files/templates/login_2fa.html @@ -12,7 +12,7 @@ 2-Step Login - {{'SITE_NAME' | app_config}} - + diff --git a/files/templates/settings.html b/files/templates/settings.html index 582379b3a..1f44e36e6 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -31,7 +31,7 @@ - + {% if v.agendaposter %}{% elif v.css %}{% endif %} diff --git a/files/templates/settings2.html b/files/templates/settings2.html index 7652899c6..df81dc38e 100644 --- a/files/templates/settings2.html +++ b/files/templates/settings2.html @@ -36,10 +36,10 @@ {% if v %} - + {% else %} - + {% endif %} diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index 41549f5e0..18128ebec 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -28,7 +28,7 @@ {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}Sign up - {{'SITE_NAME' | app_config}}{% endif %} - + diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index 7c6afe350..762934a6b 100644 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -29,7 +29,7 @@ {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}{{'SITE_NAME' | app_config}}{% endif %} - + diff --git a/files/templates/submit.html b/files/templates/submit.html index 3eef78be2..1b45ffab6 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -23,11 +23,11 @@ {% block stylesheets %} {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} {% endblock %} From 987a2fde089e1b564ae0c4e385c58e36bbe86466 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Dec 2021 21:36:39 +0200 Subject: [PATCH 05/16] sdfsdf --- files/templates/authforms.html | 4 ++-- files/templates/default.html | 4 ++-- files/templates/log.html | 4 ++-- files/templates/login_2fa.html | 2 +- files/templates/settings.html | 2 +- files/templates/settings2.html | 4 ++-- files/templates/sign_up.html | 2 +- files/templates/sign_up_failed_ref.html | 2 +- files/templates/submit.html | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 912e01895..198c27589 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -13,11 +13,11 @@ {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/default.html b/files/templates/default.html index ead207b7b..9e5c8718b 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -4,12 +4,12 @@ {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/log.html b/files/templates/log.html index 454bbfa82..472d39ec0 100644 --- a/files/templates/log.html +++ b/files/templates/log.html @@ -6,11 +6,11 @@ {% block content %} {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %}
diff --git a/files/templates/login_2fa.html b/files/templates/login_2fa.html index cd68a5cf6..543ee6ebd 100644 --- a/files/templates/login_2fa.html +++ b/files/templates/login_2fa.html @@ -12,7 +12,7 @@ 2-Step Login - {{'SITE_NAME' | app_config}} - + diff --git a/files/templates/settings.html b/files/templates/settings.html index 1f44e36e6..ef7b0be9a 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -31,7 +31,7 @@ - + {% if v.agendaposter %}{% elif v.css %}{% endif %} diff --git a/files/templates/settings2.html b/files/templates/settings2.html index df81dc38e..09f259690 100644 --- a/files/templates/settings2.html +++ b/files/templates/settings2.html @@ -36,10 +36,10 @@ {% if v %} - + {% else %} - + {% endif %} diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index 18128ebec..7805104ea 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -28,7 +28,7 @@ {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}Sign up - {{'SITE_NAME' | app_config}}{% endif %} - + diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index 762934a6b..e6cc16c76 100644 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -29,7 +29,7 @@ {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}{{'SITE_NAME' | app_config}}{% endif %} - + diff --git a/files/templates/submit.html b/files/templates/submit.html index 1b45ffab6..dc5aa7b38 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -23,11 +23,11 @@ {% block stylesheets %} {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} {% endblock %} From d7a34752e1169b810c413de40ae3bf476edbe99c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Dec 2021 21:39:48 +0200 Subject: [PATCH 06/16] fdsfds --- files/routes/comments.py | 8 ++++++-- files/routes/posts.py | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index 23ab85e8a..633544e42 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -157,7 +157,9 @@ def api_comment(v): else: top_comment_id = parent.top_comment_id else: abort(400) - body = request.values.get("body", "").strip()[:10000] + body = request.values.get("body", "").strip()[:10000].replace(' ','\n') + for i in re.finditer('(^|\n)(?!.*http)(.*)', body): + body = body.replace(i.group(2), i.group(2).upper()) if v.marseyawarded: if time.time() > v.marseyawarded: @@ -615,7 +617,9 @@ def edit_comment(cid, v): if c.is_banned or c.deleted_utc > 0: abort(403) - body = request.values.get("body", "").strip()[:10000] + body = request.values.get("body", "").strip()[:10000].replace(' ','\n') + for i in re.finditer('(^|\n)(?!.*http)(.*)', body): + body = body.replace(i.group(2), i.group(2).upper()) if len(body) < 1: return {"error":"You have to actually type something!"}, 400 if body != c.body and body != "": diff --git a/files/routes/posts.py b/files/routes/posts.py index 7598798ef..bbbe5e26c 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -335,8 +335,12 @@ def edit_post(pid, v): if p.author_id != v.id and not (v.admin_level > 1 and v.admin_level > 2): abort(403) - title = request.values.get("title", "").strip() - body = request.values.get("body", "").strip() + title = request.values.get("title", "").strip().replace(' ','\n') + for i in re.finditer('(^|\n)(?!.*http)(.*)', title): + title = title.replace(i.group(2), i.group(2).upper()) + body = request.values.get("body", "").strip().replace(' ','\n') + for i in re.finditer('(^|\n)(?!.*http)(.*)', body): + body = body.replace(i.group(2), i.group(2).upper()) if len(body) > 10000: return {"error":"Character limit is 10000!"}, 403 @@ -669,7 +673,9 @@ def submit_post(v): if request.content_length > 8 * 1024 * 1024: return "Max file size is 8 MB.", 413 elif request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 - title = request.values.get("title", "").strip()[:500] + title = request.values.get("title", "").strip()[:500].replace(' ','\n') + for i in re.finditer('(^|\n)(?!.*http)(.*)', title): + title = title.replace(i.group(2), i.group(2).upper()) url = request.values.get("url", "").strip() if v.agendaposter and not v.marseyawarded: @@ -678,7 +684,9 @@ def submit_post(v): title = censor_slurs2(title).upper().replace(' ME ', f' @{v.username} ') title_html = filter_emojis_only(title) - body = request.values.get("body", "").strip() + body = request.values.get("body", "").strip().replace(' ','\n') + for i in re.finditer('(^|\n)(?!.*http)(.*)', body): + body = body.replace(i.group(2), i.group(2).upper()) if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 40 From 12e35f26d234382044a63ae0b3db4ce13414c228 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Dec 2021 21:53:16 +0200 Subject: [PATCH 08/16] fsddfs --- files/routes/comments.py | 3 +++ files/routes/posts.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/files/routes/comments.py b/files/routes/comments.py index 633544e42..9ec1fdc24 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -160,6 +160,7 @@ def api_comment(v): body = request.values.get("body", "").strip()[:10000].replace(' ','\n') for i in re.finditer('(^|\n)(?!.*http)(.*)', body): body = body.replace(i.group(2), i.group(2).upper()) + body = body.replace('\n\n','%&$').replace('\n',' ').replace('%&$','\n\n') if v.marseyawarded: if time.time() > v.marseyawarded: @@ -620,6 +621,8 @@ def edit_comment(cid, v): body = request.values.get("body", "").strip()[:10000].replace(' ','\n') for i in re.finditer('(^|\n)(?!.*http)(.*)', body): body = body.replace(i.group(2), i.group(2).upper()) + body = body.replace('\n\n','%&$').replace('\n',' ').replace('%&$','\n\n') + if len(body) < 1: return {"error":"You have to actually type something!"}, 400 if body != c.body and body != "": diff --git a/files/routes/posts.py b/files/routes/posts.py index bbbe5e26c..984ce5273 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -338,9 +338,12 @@ def edit_post(pid, v): title = request.values.get("title", "").strip().replace(' ','\n') for i in re.finditer('(^|\n)(?!.*http)(.*)', title): title = title.replace(i.group(2), i.group(2).upper()) + title = title.replace('\n\n','%&$').replace('\n',' ').replace('%&$','\n\n') + body = request.values.get("body", "").strip().replace(' ','\n') for i in re.finditer('(^|\n)(?!.*http)(.*)', body): body = body.replace(i.group(2), i.group(2).upper()) + body = body.replace('\n\n','%&$').replace('\n',' ').replace('%&$','\n\n') if len(body) > 10000: return {"error":"Character limit is 10000!"}, 403 @@ -676,6 +679,8 @@ def submit_post(v): title = request.values.get("title", "").strip()[:500].replace(' ','\n') for i in re.finditer('(^|\n)(?!.*http)(.*)', title): title = title.replace(i.group(2), i.group(2).upper()) + title = title.replace('\n\n','%&$').replace('\n',' ').replace('%&$','\n\n') + url = request.values.get("url", "").strip() if v.agendaposter and not v.marseyawarded: @@ -687,6 +692,7 @@ def submit_post(v): body = request.values.get("body", "").strip().replace(' ','\n') for i in re.finditer('(^|\n)(?!.*http)(.*)', body): body = body.replace(i.group(2), i.group(2).upper()) + body = body.replace('\n\n','%&$').replace('\n',' ').replace('%&$','\n\n') if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 40 From 331b37a8b969deb6b7f2f1f2c32f9e38d34d24c8 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Dec 2021 22:02:02 +0200 Subject: [PATCH 09/16] fdsfds --- files/routes/posts.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/files/routes/posts.py b/files/routes/posts.py index 984ce5273..55c338209 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -335,10 +335,7 @@ def edit_post(pid, v): if p.author_id != v.id and not (v.admin_level > 1 and v.admin_level > 2): abort(403) - title = request.values.get("title", "").strip().replace(' ','\n') - for i in re.finditer('(^|\n)(?!.*http)(.*)', title): - title = title.replace(i.group(2), i.group(2).upper()) - title = title.replace('\n\n','%&$').replace('\n',' ').replace('%&$','\n\n') + title = request.values.get("title", "").strip().upper() body = request.values.get("body", "").strip().replace(' ','\n') for i in re.finditer('(^|\n)(?!.*http)(.*)', body): @@ -676,10 +673,7 @@ def submit_post(v): if request.content_length > 8 * 1024 * 1024: return "Max file size is 8 MB.", 413 elif request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 - title = request.values.get("title", "").strip()[:500].replace(' ','\n') - for i in re.finditer('(^|\n)(?!.*http)(.*)', title): - title = title.replace(i.group(2), i.group(2).upper()) - title = title.replace('\n\n','%&$').replace('\n',' ').replace('%&$','\n\n') + title = request.values.get("title", "").strip()[:500].upper() url = request.values.get("url", "").strip() From 2d7b038577fd3fd52ebff6e20e7761d4c01b1dad Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Dec 2021 22:08:17 +0200 Subject: [PATCH 10/16] dsfds --- files/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/__main__.py b/files/__main__.py index 816ecfb11..fb6c44613 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -122,11 +122,11 @@ def teardown_request(error): @app.after_request def after_request(response): - if session.get("favorite_emojis"): del session["favorite_emojis"] response.headers.add("Strict-Transport-Security", "max-age=31536000") + response.headers.add("Referrer-Policy", "same-origin") response.headers.add("X-Frame-Options", "deny") - response.headers.add("Content-Security-Policy", "script-src 'self' 'unsafe-inline' 'unsafe-eval' ajax.cloudflare.com; connect-src 'self' tls-use1.fpapi.io api.fpjs.io 02ddcc80-b8db-42be-9022-44c546b4dce6.pushnotifications.pusher.com; object-src 'none';") return response + from files.routes import * \ No newline at end of file From bfcf44bd47860130449f53cb6c1e5b0b50217112 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Dec 2021 22:09:20 +0200 Subject: [PATCH 11/16] fsddsf --- files/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/files/__main__.py b/files/__main__.py index fb6c44613..41b97b033 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -124,7 +124,6 @@ def teardown_request(error): def after_request(response): response.headers.add("Strict-Transport-Security", "max-age=31536000") - response.headers.add("Referrer-Policy", "same-origin") response.headers.add("X-Frame-Options", "deny") return response From 9fad1004a7a1250211c86b5c0d1ed235944328e7 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Dec 2021 22:10:12 +0200 Subject: [PATCH 12/16] sdfdfs --- files/__main__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/files/__main__.py b/files/__main__.py index 41b97b033..751c3b1e5 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -125,6 +125,7 @@ def after_request(response): response.headers.add("Strict-Transport-Security", "max-age=31536000") response.headers.add("X-Frame-Options", "deny") + response.headers.add("Content-Security-Policy", "script-src 'self' 'unsafe-inline' 'unsafe-eval' ajax.cloudflare.com; connect-src 'self' tls-use1.fpapi.io api.fpjs.io 02ddcc80-b8db-42be-9022-44c546b4dce6.pushnotifications.pusher.com; object-src 'none';") return response From c36002e5e72a5b134844843ee1d1eaad7655413a Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Dec 2021 22:12:20 +0200 Subject: [PATCH 13/16] fdsdfs --- files/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/__main__.py b/files/__main__.py index 751c3b1e5..fb6c44613 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -124,8 +124,8 @@ def teardown_request(error): def after_request(response): response.headers.add("Strict-Transport-Security", "max-age=31536000") + response.headers.add("Referrer-Policy", "same-origin") response.headers.add("X-Frame-Options", "deny") - response.headers.add("Content-Security-Policy", "script-src 'self' 'unsafe-inline' 'unsafe-eval' ajax.cloudflare.com; connect-src 'self' tls-use1.fpapi.io api.fpjs.io 02ddcc80-b8db-42be-9022-44c546b4dce6.pushnotifications.pusher.com; object-src 'none';") return response From 1fc1f8dae0c7ebf6e53ccd3346018574d38ddb36 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Dec 2021 22:14:57 +0200 Subject: [PATCH 14/16] fsdfds --- files/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/files/__main__.py b/files/__main__.py index fb6c44613..41b97b033 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -124,7 +124,6 @@ def teardown_request(error): def after_request(response): response.headers.add("Strict-Transport-Security", "max-age=31536000") - response.headers.add("Referrer-Policy", "same-origin") response.headers.add("X-Frame-Options", "deny") return response From 7bc73c82737b25dd6a8bf3d6147de1fd7d5c6d2b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Dec 2021 22:20:52 +0200 Subject: [PATCH 15/16] fdsfd --- files/routes/users.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/files/routes/users.py b/files/routes/users.py index adc32dca1..0d299f601 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -817,7 +817,18 @@ def user_profile_uid(id): try: id = int(id, 36) except: abort(404) x=get_account(id) - return redirect(x.profile_url) + + purl = x.profile_url + if not 'images/' in purl: return redirect(purl) + + path = purl.split('images/')[1] + resp = make_response(send_from_directory('/images', path)) + resp.headers.remove("Cache-Control") + resp.headers.add("Cache-Control", "public, max-age=2628000") + if request.path.endswith('.webp'): + resp.headers.remove("Content-Type") + resp.headers.add("Content-Type", "image/webp") + return resp @app.get("/@/pic") @limiter.exempt From 9455bae222caf5ee3b7e64cf54a966af53caac24 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Dec 2021 22:24:34 +0200 Subject: [PATCH 16/16] fsdfsd --- files/routes/comments.py | 4 ++-- files/routes/posts.py | 8 ++++---- files/routes/settings.py | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index 9ec1fdc24..e55fb5a5c 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -195,7 +195,7 @@ def api_comment(v): file=request.files["file"] if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400 - name = f'/images/{time.time()}'.replace('.','') + '.webp' + name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) url = request.host_url[:-1] + process_image(name) @@ -728,7 +728,7 @@ def edit_comment(cid, v): file=request.files["file"] if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400 - name = f'/images/{time.time()}'.replace('.','') + '.webp' + name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) url = request.host_url[:-1] + process_image(name) diff --git a/files/routes/posts.py b/files/routes/posts.py index 55c338209..359b262c1 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -381,7 +381,7 @@ def edit_post(pid, v): file=request.files["file"] if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400 - name = f'/images/{time.time()}'.replace('.','') + '.webp' + name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) url = request.host_url[:-1] + process_image(name) @@ -650,7 +650,7 @@ def thumbnail_thread(pid): db.close() return - name = f'/images/{time.time()}'.replace('.','') + '.webp' + name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' with open(name, "wb") as file: for chunk in image_req.iter_content(1024): @@ -872,7 +872,7 @@ def submit_post(v): file=request.files["file2"] if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400 - name = f'/images/{time.time()}'.replace('.','') + '.webp' + name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) url = request.host_url[:-1] + process_image(name) @@ -960,7 +960,7 @@ def submit_post(v): ), 403 if file.content_type.startswith('image/'): - name = f'/images/{time.time()}'.replace('.','') + '.webp' + name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) new_post.url = request.host_url[:-1] + process_image(name) diff --git a/files/routes/settings.py b/files/routes/settings.py index ea82237d9..e9aeb6a0e 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -124,7 +124,7 @@ def settings_profile_post(v): if request.headers.get("Authorization"): return {"error": f"Image files only"}, 400 else: return render_template("settings_profile.html", v=v, error=f"Image files only."), 400 - name = f'/images/{time.time()}'.replace('.','') + '.webp' + name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) url = request.host_url[:-1] + process_image(name) @@ -314,7 +314,7 @@ def settings_profile_post(v): if request.headers.get("Authorization"): return {"error": f"Image files only"}, 400 else: return render_template("settings_profile.html", v=v, error=f"Image files only."), 400 - name = f'/images/{time.time()}'.replace('.','') + '.webp' + name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) url = request.host_url[:-1] + process_image(name) @@ -720,7 +720,7 @@ def settings_images_profile(v): file = request.files["profile"] - name = f'/images/{time.time()}'.replace('.','') + '.webp' + name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) highres = request.host_url[:-1] + process_image(name) @@ -756,7 +756,7 @@ def settings_images_banner(v): file = request.files["banner"] - name = f'/images/{time.time()}'.replace('.','') + '.webp' + name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' file.save(name) bannerurl = request.host_url[:-1] + process_image(name)