diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 8b8f14b95..be7d8aa45 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -214,7 +214,7 @@ def with_sigalrm_timeout(timeout: int): @with_sigalrm_timeout(2) -def sanitize(sanitized, edit=False, limit_pings=False, showmore=True): +def sanitize(sanitized, edit=False, limit_pings=0, showmore=True): sanitized = sanitized.strip() sanitized = normalize_url(sanitized) @@ -246,7 +246,7 @@ def sanitize(sanitized, edit=False, limit_pings=False, showmore=True): matches = [m for m in mention_regex.finditer(sanitized) if m] names = set(m.group(2) for m in matches) - if limit_pings and len(names) > 3 and not v.admin_level: abort(406) + if limit_pings and len(names) > limit_pings and not v.admin_level: abort(406) users = get_users(names, graceful=True) for u in users: diff --git a/files/routes/comments.py b/files/routes/comments.py index e38a57e87..ab7a189fc 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -285,7 +285,7 @@ def comment(v): if v.agendaposter and not v.marseyawarded and parent_post.id not in ADMIGGERS and parent_post.sub != 'chudrama': body = torture_ap(body, v.username) - body_html = sanitize(body, limit_pings=True) + body_html = sanitize(body, limit_pings=3) if parent_post.id not in ADMIGGERS and '!slots' not in body.lower() and '!blackjack' not in body.lower() and '!wordle' not in body.lower() and AGENDAPOSTER_PHRASE not in body.lower() and parent_post.sub != 'chudrama': @@ -715,7 +715,7 @@ def edit_comment(cid, v): body = body.strip() - body_html = sanitize(body, edit=True, limit_pings=True) + body_html = sanitize(body, edit=True, limit_pings=3) if len(body_html) > 20000: abort(400) diff --git a/files/routes/errors.py b/files/routes/errors.py index 47042b869..5fc222b6b 100644 --- a/files/routes/errors.py +++ b/files/routes/errors.py @@ -23,7 +23,7 @@ def error_401(e): @app.errorhandler(406) def error_406(e): - if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "You can't ping more than 3 people!"}, 406 + if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "Too many pings: max limit is 3 for comments and 50 for posts"}, 406 else: return render_template('errors/406.html', err=True), 406 @app.errorhandler(403) diff --git a/files/routes/posts.py b/files/routes/posts.py index a4441572d..e784a7560 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -446,7 +446,7 @@ def edit_post(pid, v): g.db.add(option) - body_html = sanitize(body, edit=True, limit_pings=True, showmore=False) + body_html = sanitize(body, edit=True, limit_pings=100, showmore=False) if v.id == p.author_id and v.marseyawarded and marseyaward_body_regex.search(body_html): return {"error":"You can only type marseys!"}, 403 @@ -899,7 +899,7 @@ def submit_post(v, sub=None): body = body.strip() - body_html = sanitize(body, limit_pings=True, showmore=False) + body_html = sanitize(body, limit_pings=100, showmore=False) if v.marseyawarded and marseyaward_body_regex.search(body_html): return error("You can only type marseys!") diff --git a/files/templates/errors/406.html b/files/templates/errors/406.html index 7bfa166cd..c2154f1db 100644 --- a/files/templates/errors/406.html +++ b/files/templates/errors/406.html @@ -13,7 +13,7 @@ :#marseyrage

 		

Too many pings

-

You can't ping more than 3 people!

+

Max limit is 3 for comments and 50 for posts

Go to frontpage