forked from rDrama/rDrama
limit the "show more" button to comments only
parent
749f0b7f0a
commit
9c6c264307
|
@ -337,7 +337,7 @@ def handle_youtube_links(url):
|
||||||
return html
|
return html
|
||||||
|
|
||||||
@with_sigalrm_timeout(10)
|
@with_sigalrm_timeout(10)
|
||||||
def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_emojis=False, snappy=False, chat=False, blackjack=None):
|
def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis=False, snappy=False, chat=False, blackjack=None):
|
||||||
sanitized = sanitized.strip()
|
sanitized = sanitized.strip()
|
||||||
if not sanitized: return ''
|
if not sanitized: return ''
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ def edit_rules_get(v):
|
||||||
@admin_level_required(PERMS['EDIT_RULES'])
|
@admin_level_required(PERMS['EDIT_RULES'])
|
||||||
def edit_rules_post(v):
|
def edit_rules_post(v):
|
||||||
rules = request.values.get('rules', '').strip()
|
rules = request.values.get('rules', '').strip()
|
||||||
rules = sanitize(rules, blackjack="rules", showmore=False)
|
rules = sanitize(rules, blackjack="rules")
|
||||||
|
|
||||||
with open(f'files/templates/rules_{SITE_NAME}.html', 'w+', encoding="utf-8") as f:
|
with open(f'files/templates/rules_{SITE_NAME}.html', 'w+', encoding="utf-8") as f:
|
||||||
f.write(rules)
|
f.write(rules)
|
||||||
|
|
|
@ -439,7 +439,7 @@ def award_thing(v, thing_type, id):
|
||||||
body = thing.body
|
body = thing.body
|
||||||
if author.owoify: body = owoify(body)
|
if author.owoify: body = owoify(body)
|
||||||
body = marsify(body)
|
body = marsify(body)
|
||||||
thing.body_html = sanitize(body, limit_pings=5)
|
thing.body_html = sanitize(body, limit_pings=5, showmore=True)
|
||||||
g.db.add(thing)
|
g.db.add(thing)
|
||||||
elif "Vampire" in kind and kind == v.house:
|
elif "Vampire" in kind and kind == v.house:
|
||||||
if author.bite: author.bite += 172800
|
if author.bite: author.bite += 172800
|
||||||
|
@ -465,7 +465,7 @@ def award_thing(v, thing_type, id):
|
||||||
body = thing.body
|
body = thing.body
|
||||||
body = owoify(body)
|
body = owoify(body)
|
||||||
if author.marsify: body = marsify(body)
|
if author.marsify: body = marsify(body)
|
||||||
thing.body_html = sanitize(body, limit_pings=5)
|
thing.body_html = sanitize(body, limit_pings=5, showmore=True)
|
||||||
g.db.add(thing)
|
g.db.add(thing)
|
||||||
elif ("Femboy" in kind and kind == v.house) or kind == 'rainbow':
|
elif ("Femboy" in kind and kind == v.house) or kind == 'rainbow':
|
||||||
if author.rainbow: author.rainbow += 86400
|
if author.rainbow: author.rainbow += 86400
|
||||||
|
|
|
@ -240,7 +240,7 @@ def comment(v:User):
|
||||||
if v.owoify: body_for_sanitize = owoify(body_for_sanitize)
|
if v.owoify: body_for_sanitize = owoify(body_for_sanitize)
|
||||||
if v.marsify: body_for_sanitize = marsify(body_for_sanitize)
|
if v.marsify: body_for_sanitize = marsify(body_for_sanitize)
|
||||||
|
|
||||||
body_html = sanitize(body_for_sanitize, limit_pings=5, count_emojis=not v.marsify)
|
body_html = sanitize(body_for_sanitize, limit_pings=5, showmore=True, count_emojis=not v.marsify)
|
||||||
|
|
||||||
if post_target.id not in ADMIGGER_THREADS and not (v.agendaposter and v.agendaposter_phrase in body.lower()):
|
if post_target.id not in ADMIGGER_THREADS and not (v.agendaposter and v.agendaposter_phrase in body.lower()):
|
||||||
existing = g.db.query(Comment.id).filter(
|
existing = g.db.query(Comment.id).filter(
|
||||||
|
@ -629,7 +629,7 @@ def edit_comment(cid, v):
|
||||||
if v.marsify:
|
if v.marsify:
|
||||||
body_for_sanitize = marsify(body_for_sanitize)
|
body_for_sanitize = marsify(body_for_sanitize)
|
||||||
|
|
||||||
body_html = sanitize(body_for_sanitize, golden=False, limit_pings=5)
|
body_html = sanitize(body_for_sanitize, golden=False, limit_pings=5, showmore=True)
|
||||||
|
|
||||||
if len(body_html) > COMMENT_BODY_HTML_LENGTH_LIMIT: abort(400)
|
if len(body_html) > COMMENT_BODY_HTML_LENGTH_LIMIT: abort(400)
|
||||||
|
|
||||||
|
|
|
@ -574,7 +574,7 @@ def submit_post(v:User, sub=None):
|
||||||
body = process_files(request.files, v, body)
|
body = process_files(request.files, v, body)
|
||||||
body = body.strip()[:POST_BODY_LENGTH_LIMIT(v)] # process_files() adds content to the body, so we need to re-strip
|
body = body.strip()[:POST_BODY_LENGTH_LIMIT(v)] # process_files() adds content to the body, so we need to re-strip
|
||||||
|
|
||||||
body_html = sanitize(body, count_emojis=True, limit_pings=100, showmore=False)
|
body_html = sanitize(body, count_emojis=True, limit_pings=100)
|
||||||
|
|
||||||
if v.marseyawarded and marseyaward_body_regex.search(body_html):
|
if v.marseyawarded and marseyaward_body_regex.search(body_html):
|
||||||
abort(400, "You can only type marseys!")
|
abort(400, "You can only type marseys!")
|
||||||
|
@ -1040,7 +1040,7 @@ def edit_post(pid, v):
|
||||||
body = body.strip()[:POST_BODY_LENGTH_LIMIT(v)] # process_files() may be adding stuff to the body
|
body = body.strip()[:POST_BODY_LENGTH_LIMIT(v)] # process_files() may be adding stuff to the body
|
||||||
|
|
||||||
if body != p.body:
|
if body != p.body:
|
||||||
body_html = sanitize(body, golden=False, limit_pings=100, showmore=False)
|
body_html = sanitize(body, golden=False, limit_pings=100)
|
||||||
|
|
||||||
if v.id == p.author_id and v.marseyawarded and marseyaward_body_regex.search(body_html):
|
if v.id == p.author_id and v.marseyawarded and marseyaward_body_regex.search(body_html):
|
||||||
abort(403, "You can only type marseys!")
|
abort(403, "You can only type marseys!")
|
||||||
|
|
|
@ -455,7 +455,7 @@ def post_sub_sidebar(v:User, sub):
|
||||||
if v.shadowbanned: return redirect(f'/h/{sub}/settings')
|
if v.shadowbanned: return redirect(f'/h/{sub}/settings')
|
||||||
|
|
||||||
sub.sidebar = request.values.get('sidebar', '').strip()[:10000]
|
sub.sidebar = request.values.get('sidebar', '').strip()[:10000]
|
||||||
sub.sidebar_html = sanitize(sub.sidebar, blackjack=f"/h/{sub} sidebar", showmore=False)
|
sub.sidebar_html = sanitize(sub.sidebar, blackjack=f"/h/{sub} sidebar")
|
||||||
if len(sub.sidebar_html) > 20000: abort(400, "Sidebar is too big!")
|
if len(sub.sidebar_html) > 20000: abort(400, "Sidebar is too big!")
|
||||||
|
|
||||||
g.db.add(sub)
|
g.db.add(sub)
|
||||||
|
|
Loading…
Reference in New Issue