limit polls to 10 options to prevent spam

pull/15/head
Aevann1 2022-11-25 23:33:38 +02:00
parent c5446b3a39
commit e4b521a63f
2 changed files with 8 additions and 8 deletions

View File

@ -132,12 +132,12 @@ def comment(v):
abort(403, "You can't reply to users who have blocked you or users that you have blocked.") abort(403, "You can't reply to users who have blocked you or users that you have blocked.")
options = [] options = []
for i in poll_regex.finditer(body): for i in list(poll_regex.finditer(body))[:10]:
options.append(i.group(1)) options.append(i.group(1))
body = body.replace(i.group(0), "") body = body.replace(i.group(0), "")
choices = [] choices = []
for i in choice_regex.finditer(body): for i in list(choice_regex.finditer(body))[:10]:
choices.append(i.group(1)) choices.append(i.group(1))
body = body.replace(i.group(0), "") body = body.replace(i.group(0), "")
@ -390,7 +390,7 @@ def edit_comment(cid, v):
elif v.bird and len(body) > 140: elif v.bird and len(body) > 140:
abort(403, "You have to type less than 140 characters!") abort(403, "You have to type less than 140 characters!")
for i in poll_regex.finditer(body): for i in list(poll_regex.finditer(body))[:10]:
body = body.replace(i.group(0), "") body = body.replace(i.group(0), "")
body_html = filter_emojis_only(i.group(1)) body_html = filter_emojis_only(i.group(1))
if len(body_html) > 500: abort(400, "Poll option too long!") if len(body_html) > 500: abort(400, "Poll option too long!")
@ -401,7 +401,7 @@ def edit_comment(cid, v):
) )
g.db.add(option) g.db.add(option)
for i in choice_regex.finditer(body): for i in list(choice_regex.finditer(body))[:10]:
body = body.replace(i.group(0), "") body = body.replace(i.group(0), "")
body_html = filter_emojis_only(i.group(1)) body_html = filter_emojis_only(i.group(1))
if len(body_html) > 500: abort(400, "Poll option too long!") if len(body_html) > 500: abort(400, "Poll option too long!")

View File

@ -360,7 +360,7 @@ def edit_post(pid, v):
) )
g.db.add(bet) g.db.add(bet)
for i in poll_regex.finditer(body): for i in list(poll_regex.finditer(body))[:10]:
body = body.replace(i.group(0), "") body = body.replace(i.group(0), "")
body_html = filter_emojis_only(i.group(1)) body_html = filter_emojis_only(i.group(1))
if len(body_html) > 500: abort(400, "Poll option too long!") if len(body_html) > 500: abort(400, "Poll option too long!")
@ -371,7 +371,7 @@ def edit_post(pid, v):
) )
g.db.add(option) g.db.add(option)
for i in choice_regex.finditer(body): for i in list(choice_regex.finditer(body))[:10]:
body = body.replace(i.group(0), "") body = body.replace(i.group(0), "")
body_html = filter_emojis_only(i.group(1)) body_html = filter_emojis_only(i.group(1))
if len(body_html) > 500: abort(400, "Poll option too long!") if len(body_html) > 500: abort(400, "Poll option too long!")
@ -754,12 +754,12 @@ def submit_post(v, sub=None):
body = body.replace(i.group(0), "") body = body.replace(i.group(0), "")
options = [] options = []
for i in poll_regex.finditer(body): for i in list(poll_regex.finditer(body))[:10]:
options.append(i.group(1)) options.append(i.group(1))
body = body.replace(i.group(0), "") body = body.replace(i.group(0), "")
choices = [] choices = []
for i in choice_regex.finditer(body): for i in list(choice_regex.finditer(body))[:10]:
choices.append(i.group(1)) choices.append(i.group(1))
body = body.replace(i.group(0), "") body = body.replace(i.group(0), "")