From a4b0565b5a9f331cabc918ac5a2ca802deb6175b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 1 May 2022 23:48:53 +0200 Subject: [PATCH] sfd --- files/helpers/wrappers.py | 4 ++++ files/routes/comments.py | 10 ---------- files/routes/errors.py | 2 +- files/routes/posts.py | 10 ---------- files/routes/settings.py | 13 ------------- files/routes/subs.py | 8 -------- files/templates/errors/413.html | 4 ++-- 7 files changed, 7 insertions(+), 44 deletions(-) diff --git a/files/helpers/wrappers.py b/files/helpers/wrappers.py index 38c9b3e76..9c6bafe34 100644 --- a/files/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -35,6 +35,10 @@ def get_logged_in_user(): if request.method.lower() != "get" and app.config['SETTINGS']['Read-only mode'] and not (v and v.admin_level): abort(403) + if v and v.patron: + if request.content_length > 16 * 1024 * 1024: abort(413) + elif request.content_length > 8 * 1024 * 1024: abort(413) + return v def check_ban_evade(v): diff --git a/files/routes/comments.py b/files/routes/comments.py index d17309c31..145a6af0f 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -164,11 +164,6 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None): def api_comment(v): if v.is_suspended: return {"error": "You can't perform this action while banned."}, 403 - if v.admin_level < 3: - if v and v.patron: - if request.content_length > 16 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - elif request.content_length > 8 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - parent_submission = request.values.get("submission").strip() parent_fullname = request.values.get("parent_fullname").strip() @@ -675,11 +670,6 @@ def api_comment(v): @auth_required def edit_comment(cid, v): - if v.admin_level < 3: - if v and v.patron: - if request.content_length > 16 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - elif request.content_length > 8 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - c = get_comment(cid, v=v) if c.author_id != v.id: abort(403) diff --git a/files/routes/errors.py b/files/routes/errors.py index dbb017e6c..6ef59640a 100644 --- a/files/routes/errors.py +++ b/files/routes/errors.py @@ -49,7 +49,7 @@ def error_405(e): def error_413(e): return {"error": "Max file size is 8 MB (16 MB for paypigs)"}, 413 if request.headers.get("Authorization") or request.headers.get("xhr"): - return {"error": "Max image size is 8 MB (16 MB for paypigs)"}, 413 + return {"error": "Max file size is 8 MB (16 MB for paypigs)"}, 413 else: return render_template('errors/413.html', err=True), 413 @app.errorhandler(429) diff --git a/files/routes/posts.py b/files/routes/posts.py index 680ad3723..dfe7ef380 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -421,11 +421,6 @@ def morecomments(v, cid): @limiter.limit("1/second;30/minute;200/hour;1000/day") @auth_required def edit_post(pid, v): - if v.admin_level < 3: - if v and v.patron: - if request.content_length > 16 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - elif request.content_length > 8 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - p = get_post(pid) if p.author_id != v.id and not (v.admin_level > 1 and v.admin_level > 2): abort(403) @@ -890,11 +885,6 @@ def submit_post(v, sub=None): if v.is_suspended: return error("You can't perform this action while banned.") - if v.admin_level < 3: - if v and v.patron: - if request.content_length > 16 * 1024 * 1024: return error( "Max file size is 8 MB (16 MB for paypigs).") - elif request.content_length > 8 * 1024 * 1024: return error( "Max file size is 8 MB (16 MB for paypigs).") - if v.agendaposter and not v.marseyawarded: title = torture_ap(title, v.username) title_html = filter_emojis_only(title, graceful=True) diff --git a/files/routes/settings.py b/files/routes/settings.py index 11faddc05..185533e8b 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -40,11 +40,6 @@ def removebackground(v): @limiter.limit("1/second;30/minute;200/hour;1000/day") @auth_required def settings_profile_post(v): - if v and v.patron: - if request.content_length > 16 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - elif request.content_length > 8 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - - updated = False if request.values.get("background", v.background) != v.background: @@ -544,10 +539,6 @@ def settings_log_out_others(v): @limiter.limit("1/second;30/minute;200/hour;1000/day") @auth_required def settings_images_profile(v): - if v and v.patron: - if request.content_length > 16 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - elif request.content_length > 8 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - if request.headers.get("cf-ipcountry") == "T1": return {"error":"Image uploads are not allowed through TOR."}, 403 file = request.files["profile"] @@ -583,10 +574,6 @@ def settings_images_profile(v): @limiter.limit("1/second;30/minute;200/hour;1000/day") @auth_required def settings_images_banner(v): - if v and v.patron: - if request.content_length > 16 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - elif request.content_length > 8 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - if request.headers.get("cf-ipcountry") == "T1": return {"error":"Image uploads are not allowed through TOR."}, 403 file = request.files["banner"] diff --git a/files/routes/subs.py b/files/routes/subs.py index 7db2a6ef8..98a0e3dea 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -354,10 +354,6 @@ def get_sub_css(sub): @limiter.limit("1/second;10/day") @is_not_permabanned def sub_banner(v, sub): - if v and v.patron: - if request.content_length > 16 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - elif request.content_length > 8 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - if request.headers.get("cf-ipcountry") == "T1": return {"error":"Image uploads are not allowed through TOR."}, 403 sub = g.db.query(Sub).filter_by(name=sub.lower().strip()).one_or_none() @@ -385,10 +381,6 @@ def sub_banner(v, sub): @limiter.limit("1/second;10/day") @is_not_permabanned def sub_sidebar(v, sub): - if v and v.patron: - if request.content_length > 16 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - elif request.content_length > 8 * 1024 * 1024: return {"error":"Max file size is 8 MB (16 MB for paypigs)."}, 413 - if request.headers.get("cf-ipcountry") == "T1": return {"error":"Image uploads are not allowed through TOR."}, 403 sub = g.db.query(Sub).filter_by(name=sub.lower().strip()).one_or_none() diff --git a/files/templates/errors/413.html b/files/templates/errors/413.html index 62b9a469e..aaa3b43ee 100644 --- a/files/templates/errors/413.html +++ b/files/templates/errors/413.html @@ -1,7 +1,7 @@ {% extends "default.html" %} {% block title %} -Max image size is 8 MB (16 MB for paypigs) +Max file size is 8 MB (16 MB for paypigs) {% endblock %} {% block pagetype %}error-413{% endblock %} @@ -12,7 +12,7 @@
:#marseyretard:

-		

Max image size is 8 MB (16 MB for paypigs)

+

Max file size is 8 MB (16 MB for paypigs)

Go to frontpage