use error()instead of abort() in sanitize

pull/164/head
Aevann 2023-06-30 23:34:29 +03:00
parent 243368c106
commit 486bacf5e6
3 changed files with 10 additions and 15 deletions

View File

@ -588,7 +588,6 @@ WERKZEUG_ERROR_DESCRIPTIONS = {
403: "You don't have the permission to access the requested resource. It is either read-protected or not readable by the server.",
404: "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.",
405: "The method is not allowed for the requested URL.",
406: "The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.",
409: "A conflict happened while processing the request. The resource might have been modified while the request was being processed.",
410: "The requested URL is no longer available on this server and there is no forwarding address. If you followed a link from a foreign page, please contact the author of this page.",
413: "The data value transmitted exceeds the capacity limit.",
@ -606,7 +605,6 @@ ERROR_TITLES = {
403: "Forbidden🙅",
404: "Not Found - where did it go?",
405: "Method Not Allowed, BAD.",
406: "Too Many Pings fuck off",
409: "Cumflict",
410: "Gone... and Forgotten",
413: "Gayload Too Large",
@ -622,7 +620,6 @@ ERROR_MSGS = {
403: "YOU AREN'T WELCOME HERE GO AWAY",
404: "Someone typed something wrong and it was probably you, please do better.",
405: "idk how anyone gets this error but if you see this, remember to follow @carpathianflorist<br>the original error text here talked about internet gremlins and wtf",
406: "Max ping limit is 5 for comments and 50 for posts",
409: "There's a conflict between what you're trying to do and what you or someone else has done and because of that you can't do what you're trying to do. So maybe like... don't try and do that? Sorry not sorry",
410: "You were too slow. The link FUCKING DIED. Request a new one and be more efficient.",
413: "That's a heckin' chonker of a file! Please make it smaller or maybe like upload it somewhere else idk<BR>jc wrote this one hi jc!<br>- carp",
@ -638,7 +635,6 @@ ERROR_MARSEYS = {
403: "marseytroll",
404: "marseyconfused",
405: "marseyretard",
406: "marseyrage",
409: "marseynoyou",
410: "marseyrave",
413: "marseychonker2",
@ -925,7 +921,6 @@ elif SITE == 'watchpeopledie.tv':
403: "Not Found",
404: "Not Found",
405: "Method Not Allowed",
406: "Too Many Pings",
409: "Mortal Conflict",
410: "Dead",
413: "Payload Too Large",
@ -939,7 +934,6 @@ elif SITE == 'watchpeopledie.tv':
403: "That wasn't found",
404: "That wasn't found.",
405: "You can't use this method here... if you keep getting this error tell us it's prolly something borked.",
406: "Max ping limit is 5 for comments and 50 for posts",
409: "There's a conflict between what you're trying to do and what you or someone else has done and because of that you can't do what you're trying to do.",
410: "This link is dead. Request a new one to try again.",
413: "You need to upload a smaller file please.",

View File

@ -337,12 +337,18 @@ def handle_youtube_links(url):
@with_sigalrm_timeout(10)
def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis=False, snappy=False, chat=False, blackjack=None):
def error(error):
if chat:
return error, 403
else:
abort(403, error)
sanitized = sanitized.strip()
if not sanitized: return ''
if "style" in sanitized and "filter" in sanitized:
if sanitized.count("blur(") + sanitized.count("drop-shadow(") > 5:
abort(400, "Too many filters!")
error("Too many filters!")
if blackjack and execute_blackjack(g.v, None, sanitized, blackjack):
sanitized = 'g'
@ -380,8 +386,10 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
v = getattr(g, 'v', None)
names = set(m.group(1) for m in mention_regex.finditer(sanitized))
if limit_pings and len(names) > limit_pings and not v.admin_level >= PERMS['POST_COMMENT_INFINITE_PINGS']:
abort(406)
error("Max ping limit is 5 for comments and 50 for posts!")
users_list = get_users(names, graceful=True)
users_dict = {}
for u in users_list:
@ -507,12 +515,6 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
links = soup.find_all("a")
def error(error):
if chat:
return error, 403
else:
abort(403, error)
if g.v and g.v.admin_level >= PERMS["IGNORE_DOMAIN_BAN"]:
banned_domains = []
else:

View File

@ -20,7 +20,6 @@ from files.__main__ import app, limiter
@app.errorhandler(403)
@app.errorhandler(404)
@app.errorhandler(405)
@app.errorhandler(406)
@app.errorhandler(409)
@app.errorhandler(410)
@app.errorhandler(413)